What problem does it solve?
This Skill prevents the most common Next.js integration failures when using CometChat’s React UI Kit, especially crashes caused by Server-Side Rendering (SSR) and React Server/Client Component boundary mistakes.
Core Features & Use Cases
- SSR prevention for CometChat imports: Ensures all files importing
@cometchat/chat-uikit-react run only in the browser using "use client" or next/dynamic with ssr: false.
- Next.js provider architecture: Provides a robust
CometChatProvider pattern for App Router and Pages Router, including safeguards against double initialization/login in React StrictMode.
- Correct route and UI placement: Shows where to put chat UI files in both App Router (
app/.../page.tsx) and Pages Router (pages/...) and how to embed CometChat in pages, modals, and drawers without breaking SSR rules.
- Production-ready token strategy: Covers server-side API route patterns to generate auth tokens without exposing secrets to the browser.
Quick Start
Update your Next.js chat components and provider to run only on the client by adding the required "use client" / ssr: false patterns, then mount the CometChatProvider in the appropriate Next.js layer (App Router layout.tsx or Pages Router _app.tsx) and create your chat route (e.g., /messages) using client-rendered CometChat UI.