FluxyChat

Getting Started

CLI and examples

Scaffold a FluxyChat app, set env vars, and mint a member JWT.

Use the scoped CLI. Bare npx create-fluxy-chat is a different package and 404s.

Hosted app

npx @fluxy-chat/create-fluxy-chat@latest my-app --mode hosted -y

That writes a Vite chat app. After pnpm setup:hosted you sign in on fluxychat.com.

Each example needs VITE_FLUXYCHAT_WORKER_URL plus a pk_ (VITE_FLUXYCHAT_PUBLISHABLE_KEY), a public room id (guest), or a member JWT. Open two tabs for anything collaborative.

Zero-backend public room: FluxyRealtimeProvider + publishableKey (pk_, POST /tokens/anonymous). Guest session still works:

<FluxyRealtimeProvider workerUrl={workerUrl} publishableKey={pk}>
  <Chat />
</FluxyRealtimeProvider>
npx @fluxy-chat/create-fluxy-chat@latest my-cursors --example live-cursors
npx @fluxy-chat/create-fluxy-chat@latest my-cursors-chat --example live-cursors-chat
npx @fluxy-chat/create-fluxy-chat@latest my-vanilla --example javascript-live-cursors
npx @fluxy-chat/create-fluxy-chat@latest my-doc --example tiptap-room
npx @fluxy-chat/create-fluxy-chat@latest my-board --example whiteboard
npx @fluxy-chat/create-fluxy-chat@latest my-draw --example draw
npx @fluxy-chat/create-fluxy-chat@latest my-comments --example comments-board
npx @fluxy-chat/create-fluxy-chat@latest my-polls --example polls
npx @fluxy-chat/create-fluxy-chat@latest my-war --example war-room
npx @fluxy-chat/create-fluxy-chat@latest my-iot --example iot-panel
npx @fluxy-chat/create-fluxy-chat@latest my-deal --example deal-room
npx @fluxy-chat/create-fluxy-chat@latest my-fleet --example fleet-panel
npx @fluxy-chat/create-fluxy-chat@latest my-game --example game-tick
npx @fluxy-chat/create-fluxy-chat@latest my-stage --example voice-stage

Cursors travel as WebSocket type: "cursor". Tiptap and the whiteboard sync Yjs on the same room. See What to build for the idea-to-example map.

Three ways to run

PathCommandYou provide
Hosted--mode hosted -yClerk on fluxychat.com after setup
Self-hostclone the repo, pnpm --filter @fluxy-chat/worker devWorker URL + project JWT
SDK-only--template react or --example from the galleryWorker URL + JWT or public room

Env vars (browser)

  • VITE_FLUXYCHAT_WORKER_URL: hosted API or wrangler dev
  • VITE_FLUXYCHAT_PUBLISHABLE_KEY: pk_ on FluxyRealtimeProvider (public rooms)
  • VITE_FLUXYCHAT_MEMBER_JWT + VITE_FLUXYCHAT_ROOM_ID: member
  • VITE_FLUXYCHAT_PUBLIC_ROOM_ID: guest via FluxyChatClient.joinPublicRoomAsGuest

Keep fc_… API keys on the server.

One room session

useChat({ roomId }) is the room session: messages, presence, cursors (sendCursor / liveCursors), broadcast (sendClientEvent), agents (invokeAgent). Yjs is a second binary socket on the same Durable Object.

For cursors only, useLiveCursors({ roomId }). Do not mount both unless they share sessionScope, or you open two sockets.

NeedAPI
Who is here, pointers, selectionssendCursor, liveCursors, useMyPresence / presence_patch
One-shot stampssendClientEvent (client-ephemeral-* skips webhooks)
Shared documentuseStorage / FluxyYjsProvider (@fluxy-chat/sdk/yjs)
Activity logsuseFeeds, /rooms/:id/feeds
Side-panel assistantRegisterAiKnowledge + <AiChat />
Pinned review commentsuseThreads, /comment-threads
Chat timelineuseChat messages; replies use parentId
Nested chat threaduseThread({ threadParentId }); registry GET /rooms/:id/threads
Agent on the timelineinvokeAgent

JWT mint (server)

POST {WORKER}/auth/token with X-Fluxy-Api-Key: fc_… and body { userId, roles, ttlSeconds }. Pass the JWT as FluxyRealtimeProvider authTokenProvider. Nest FluxyYjsProvider inside it, or pass token / authTokenProvider. Details: Choose your path and the auth cookbook.

Open two tabs

Cursors, presence, and chat need a second client on the same roomId. One tab is not a collab test.

On this page