Skip to content
cable
Esc
↑↓navigate↵open⌘Jpreview

Examples

Follow the runnable Cloudflare chat application from shared contract to server host and React client.

The Cloudflare chat example is a runnable application. It includes authenticated REST procedures, /openapi.json, a Hono notification route that emits to a channel, global session procedures, retained history, presence, and a React client.

Read the files in this order:

  1. src/api.ts declares the REST metadata, session.whoami, and the chat.{roomId} channel.
  2. src/chat-server.ts implements global procedures, channel authorization, events, and the channel-scoped info procedure.
  3. src/worker.ts connects those implementations to Cloudflare Durable Objects and uses Hono for /openapi.json and /notifications.
  4. src/app.tsx uses the client from a React view.

The example’s display-name bearer token is local development scaffolding. Replace identityFromRequest with your application’s authentication before deployment. Its README has the commands, endpoint calls, and local secret setup.

Was this page helpful?