1

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/blip-chat-widget@1.9.1"
          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?

juliomalves
  • 42,130
  • 20
  • 150
  • 146
dcodem
  • 11
  • 3
  • 1
    Does this answer your question: [How do you explicitly set a new property on \`window\` in TypeScript?](https://stackoverflow.com/questions/12709074/how-do-you-explicitly-set-a-new-property-on-window-in-typescript)? That's a TypeScript error because `BlipChat` isn't declared as a property in the `window` global. Declaring the property then using it as `new window.BlipChat()` should make the error go away. – juliomalves Jan 25 '22 at 15:02

0 Answers0