How to install Crisp Live Chat on Next.js
Are you using Next.js / React to create your new web application? Here is how you can add the Crisp chatbox on it in less than 2 minutes.
Create an account on Crisp.
Go to Settings. Then, Website Settings.
Next to your website, click on Settings.
Click on Setup instructions.
Click on Chatbox setup instructions.
Select HTML.

Copy the JavaScript code to retrieve your CRISP_WEBSITE_ID.

Install Crisp in your React project:
Inside your components folder, create a file crisp.js and paste this code below. Replace the CRISP_WEBSITE_ID with yours.
Make sure to replace CRISP_WEBSITE_ID with yours. Otherwise, this will not work!
Then, we tell can import Crisp in our component.
and Finally include it in your App:
Create an account on Crisp.
Go to Settings. Then, Website Settings.
Next to your website, click on Settings.
Click on Setup instructions.
Click on Chatbox setup instructions.
Select HTML.

Copy the JavaScript code to retrieve your CRISP_WEBSITE_ID.

Install Crisp in your React project:
npm install crisp-sdk-web
Inside your components folder, create a file crisp.js and paste this code below. Replace the CRISP_WEBSITE_ID with yours.
import React, { Component } from "react";
import { Crisp } from "crisp-sdk-web";
class CrispChat extends Component {
componentDidMount () {
Crisp.configure("MY_CRISP_WEBSITE_ID");
}
render () {
return null;
}
}
export default CrispChat
Make sure to replace CRISP_WEBSITE_ID with yours. Otherwise, this will not work!
Then, we tell can import Crisp in our component.
import dynamic from 'next/dynamic'
const CrispWithNoSSR = dynamic(
() => import('../components/crisp'),
{ ssr: false }
)
and Finally include it in your App:
class App extends React.Component {
render () {
return (
<Router>
<CrispWithNoSSR />
</Router>)
}
}
export default App
Updated on: 30/03/2023
Thank you!