Skip to content

Instantly share code, notes, and snippets.

@batur
Created August 18, 2021 14:33
Show Gist options
  • Save batur/87748c3cd9fed2bfb56380469cacdd61 to your computer and use it in GitHub Desktop.
Save batur/87748c3cd9fed2bfb56380469cacdd61 to your computer and use it in GitHub Desktop.
Crisp integration on Next.js(below v11.1.0)
import type { AppProps } from 'next/app';
import dynamic from 'next/dynamic';
const Crisp = dynamic(() => import('../components/Crisp'), { ssr: false });
function MyApp({ Component, pageProps }: AppProps) {
return (
<SomeProvider>
<Component {...pageProps} />
<Crisp />
</SomeProvider>
);
}
export default MyApp;
import React, { useEffect } from 'react';
import Head from 'next/head';
declare global {
interface Window {
$crisp: any;
CRISP_WEBSITE_ID: string;
}
}
const Crisp = () => {
useEffect(() => {
window.$crisp = [];
window.CRISP_WEBSITE_ID = "YOUR_WEBSITE_ID";
});
return (
<Head>
<script async src="https://client.crisp.chat/l.js" />;
</Head>
);
};
export default Crisp;
@batur
Copy link
Author

batur commented Aug 18, 2021

Crisp integration on Next.js(below v11.1.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment