cometchat-react-v7-patterns
Installation
SKILL.md
Ground truth:
@cometchat/chat-uikit-react@7. Framework mechanics (env prefixes, SSR) are baked framework knowledge; kit symbols come fromcometchat-react-v7-core. Status: catalog-verified vs installed 7.1.0 (exports-only web-v7.json).
Companion skills (read first)
cometchat-react-v7-core— install, provider,init→login→render. This skill ASSUMES it.
Use this skill when
Wiring the UI Kit into a specific React toolchain, or debugging env/routing/SSR issues.
Prerequisites & install
Covered by core. No new package.
Framework wiring (BAKED — the delta per toolchain; full recipe = fetch the docs integration page)
- Vite: env in
.envwithVITE_prefix; read viaimport.meta.env.VITE_COMETCHAT_*. init/login in an app-startup effect; mountCometChatProviderabove the chat routes. Brownfield gotcha (AUDIT-037/066): if thevite/clienttypes aren't wired,import.meta.envis untyped → strict-TS build failsTS2339: Property 'env' does not exist on ImportMeta. Scaffolds wirevite/clientdifferently by Vite version — older ones shipsrc/vite-env.d.ts(/// <reference types="vite/client" />), newer ones (Vite 8+) put"vite/client"in thetypesarray oftsconfig.app.json. Don't assume either is present — CHECK, then ensurevite/clientis referenced: add/// <reference types="vite/client" />at the top of the env-reading file (self-contained, works regardless of Vite version), or add"vite/client"totsconfig.app.jsoncompilerOptions.types, or createsrc/vite-env.d.ts. - Create React App: env with
REACT_APP_prefix; read viaprocess.env.REACT_APP_*. - Next.js: client-only kit — put init/login +
CometChatProviderin a Client Component ("use client"); env in.env.localwithNEXT_PUBLIC_*. Guard browser-only code so it never runs during SSR (App Router AND Pages Router). - React Router / Remix: two modes — v6 library mode (routing inside a Vite/CRA app, no SSR,
VITE_env) wires like Vite; v7 framework mode (SSR, the Remix successor — a legacy@remix-run/reactapp maps here) has Next-like SSR concerns → render the chat client-only (client guard /clientLoader/ a<ClientOnly>),VITE_env. Provider above the routed outlet. - Astro: the kit is a React island — mount it with
client:only="react"(never SSR it); env withPUBLIC_prefix (import.meta.env.PUBLIC_COMETCHAT_*). One island owns init/login + provider + chat. - Keep
CometChatProviderat a stable ancestor so init/login survive navigation (see-placement).
Full per-framework recipe: fetch the docs integration page via
cometchat-react-v7-core/references/docs-map.md—integration-react·integration-nextjs·integration-react-router·integration-astro(+ thenext-*/react-router-*/astro-*layout recipes). Bake only the deltas above; fetch the rest.