Crisp
Integrating Crisp live chat for customer support.
Integrate Crisp live chat into your StarterKitPro application to provide real-time customer support.
Optional Feature
Crisp is not included by default to keep the core lean. Install it if you want to add Crisp as a support option. If not configured, the default behavior might fall back to email support where applicable.
1. Installation
Install the Crisp SDK package:
2. Configuration (lib/app-config.ts
)
Add the crisp
configuration to your lib/app-config.ts
file. You'll need your Crisp Website ID.
3. Setup Environment Variable
Add your Crisp Website ID to your environment variables file (.env.local
):
Replace YOUR_CRISP_WEBSITE_ID
with the actual ID from your Crisp dashboard.
4. Create Crisp Chat Component (components/shared/crisp-chat.tsx
)
Create a new client component to initialize and manage the Crisp chat widget:
This component initializes Crisp, passes user session data (email, name) if
available, and handles hiding the chat widget on specific routes based on the
enabledRoutes
configuration.
5. Render Crisp Component (app/layout.tsx
)
Import and render the CrispChat
component within your main layout file, typically near the closing </body>
tag.
We conditionally render <CrispChat />
only if CRISP_WEBSITE_ID
is set in
the environment variables. This prevents attempting to load Crisp if it's not
configured.
6. Integrate with Error Handling (Optional)
If you want to provide users with an option to contact support via Crisp directly from an error page (e.g., a client-side error boundary), you can modify the contact button's onClick
handler.
Assuming you have a component that shows an error message and a 'Contact Support' button:
This logic first checks if Crisp is configured (appConfig.crisp.id
). If yes,
it shows and opens the Crisp chat. If not, it falls back to opening a
mailto:
link using the configured support email.
With these steps, Crisp live chat should be integrated into your application.