Created
August 18, 2021 14:33
-
-
Save batur/87748c3cd9fed2bfb56380469cacdd61 to your computer and use it in GitHub Desktop.
Crisp integration on Next.js(below v11.1.0)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Crisp integration on Next.js(below v11.1.0)