AGENT SKILL

cometchat-react-v7-patterns

Framework wiring for the React v7 UI Kit across Vite, Create React App, Next.js, React Router (incl. Remix), and Astro — provider placement, env vars, routing, SSR/islands and build pitfalls. Triggers: 'cometchat with vite', 'cometchat in next.js', 'cometchat in react router', 'cometchat in remix', 'cometchat in astro', 'env vars not working', 'cometchat provider setup', 'SSR window is not defined'.

License 许可
MIT
最近更新
2026-11-14
Stars
★ 1.6k
Forks
491

01 前言 Front Matter

name
cometchat-react-v7-patterns
license
MIT
metadata
{ "tags": "cometchat react patterns vite nextjs cra react-router remix astro provider env ssr v7", "author": "CometChat", "version": "1.0.0" }
description
Framework wiring for the React v7 UI Kit across Vite, Create React App, Next.js, React Router (incl. Remix), and Astro — provider placement, env vars, routing, SSR/islands and build pitfalls. Triggers: 'cometchat with vite', 'cometchat in next.js', 'cometchat in react router', 'cometchat in remix', 'cometchat in astro', 'env vars not working', 'cometchat provider setup', 'SSR window is not defined'.
compatibility
React >=18; Vite >=4 / CRA / Next.js >=13 / react-router(-dom) ^6–7 / Astro >=3 (@astrojs/react); @cometchat/chat-uikit-react ^7 (7.2.x, verified 7.2.4)

03 SKILL.md 正文

Ground truth: @cometchat/chat-uikit-react@7. Framework mechanics (env prefixes, SSR) are baked framework knowledge; kit symbols come from cometchat-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 .env with VITE_ prefix; read via import.meta.env.VITE_COMETCHAT_*. init/login in an app-startup effect; mount CometChatProvider above the chat routes. Brownfield gotcha (AUDIT-037/066): if the vite/client types aren't wired, import.meta.env is untyped → strict-TS build fails TS2339: Property 'env' does not exist on ImportMeta. Scaffolds wire vite/client differently by Vite version — older ones ship src/vite-env.d.ts (/// <reference types="vite/client" />), newer ones (Vite 8+) put "vite/client" in the types array of tsconfig.app.json. Don't assume either is present — CHECK, then ensure vite/client is 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" to tsconfig.app.json compilerOptions.types, or create src/vite-env.d.ts.
  • Create React App: env with REACT_APP_ prefix; read via process.env.REACT_APP_*.
  • Next.js: client-only kit — put init/login + CometChatProvider in a Client Component ("use client"); env in .env.local with NEXT_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/react app 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 with PUBLIC_ prefix (import.meta.env.PUBLIC_COMETCHAT_*). One island owns init/login + provider + chat.
  • Keep CometChatProvider at 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 (+ the next-* / react-router-* / astro-* layout recipes). Bake only the deltas above; fetch the rest.

Framework pitfalls (BAKED)

  • SSR frameworks (Next.js · React Router v7 framework mode · Astro): window is not defined / hydration errors when the kit renders on the server → render the chat client-only ("use client" in Next; client:only="react" in Astro; a client guard / clientLoader in React Router v7) and defer init to useEffect/the browser.
  • Astro: using client:load/client:visible (they SSR the component first) instead of client:only="react" → server-render crash.
  • Wrong env prefix for the toolchain (Vite/React-Router VITE_ · CRA REACT_APP_ · Next NEXT_PUBLIC_ · Astro PUBLIC_) → values are undefined at runtime.
  • Importing UI Kit CSS in multiple entry points (import once at root).
  • Auth key shipped to the client in production — use server-side token exchange (RULES.md).

Common pitfalls (BAKED)

See above; also version_conflict STOP (v6 installed) per core.

Verify it works

The app builds and chat renders on your framework (Vite / Next / React Router / Astro) with the correct env prefix and SSR guards ("use client" / ssr:false where needed).

04 同仓库更多 Skills

hashgraph-online
hashgraph-online/awesome-codex-plugins

worktable-review-with-annotations

Create, inspect, reply to, update, or resolve situated Worktable annotations. Use when feedback belongs to a Doc section, block, text range, or HTML Doc, or when the user asks to address existing review feedback and coordinate a requested artifact edit.

★ 1.6k
hashgraph-online
hashgraph-online/awesome-codex-plugins

worktable-find-and-synthesize-context

Find, assess, and synthesize context from Worktable Docs and Records. Use when the user asks what a workspace contains, wants workspace-backed research, needs current facts reconciled across artifacts, or requests a cited synthesis without changing workspace state.

★ 1.6k
hashgraph-online
hashgraph-online/awesome-codex-plugins

worktable-create-or-update-docs

Create, edit, rename, or maintain narrative Worktable Docs. Use for plans, decisions, briefs, notes, research syntheses, and other durable prose when the user requests a new artifact or a safe update to an existing one.

★ 1.6k
hashgraph-online
hashgraph-online/awesome-codex-plugins

worktable-create-or-manage-records

Organize repeated structured information as durable Worktable Records. Use for research datasets, inventories, directories, pipelines, trackers, and other collections whose items need identity, fields, filtering, links, validation, or individual updates.

★ 1.6k
hashgraph-online
hashgraph-online/awesome-codex-plugins

worktable-create-or-manage-interactive-html

Create or improve durable visual and interactive artifacts in Worktable. Use for dashboards, trackers, calculators, mini apps, slide presentations, and other requests that benefit from a polished HTML Doc.

★ 1.6k
hashgraph-online
hashgraph-online/awesome-codex-plugins

worktable-collaborate-threads

Read, answer, and hand off messages through durable Worktable threads with users or other authenticated participants. Use when the user asks to check addressed messages, reply to a participant, continue a thread, request another agent's help, wait briefly for a response, or watch for comments and messages sent to the agent.

★ 1.6k