'Error when load 3rd party libraries in NextJS

I'm using the blip-chat-widget library to load in app that uses NextJS, apparently everything works in the development environment, but in the build I have the following error:

Cannot find the name 'BlipChat'

I'm implementing the library in _app.tsx using the next/script that was included in Next 11

This is the part of the code that renders the chat:

import Script from 'next/script';  


render(): JSX.Element {
    const { Component, pageProps } = this.props;

    return (
      <Layout>
        <ErrorBoundary fallback={<ErrorPage />}>
          <QueryClientProvider client={queryClient}>
            <Component {...pageProps} />
          </QueryClientProvider>
        </ErrorBoundary>
        
       
         <Script
          src="https://unpkg.com/[email protected]"
          onLoad={() => {
            const blipClient = new BlipChat();

            blipClient
              .withAppKey('app_key')
              .withButton({ color: '#FFCC00' })
              .build();
          }}
        />
      </Layout>
    );
  }

I'm following what the documentation says to implement, but I don't know what to do to stop with the error in new BlipChat(). Does anyone know how I can resolve it?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source