Examples

Common usage patterns and recipes for Verani.

Architecture Options

Verani supports two architectures:

Per-Connection Architecture (Recommended)

Each user gets their own Durable Object. See examples/v2/ in the repository:

  • presence-connection.ts - Per-user presence connection handler
  • presence-room-coordinator.ts - Room coordinator for presence

Use createConnectionHandler() and createRoomHandler() for this pattern.

Legacy Architecture

All connections in a single Durable Object. The examples below use this pattern.

Use defineRoom() and createActorHandler() for this pattern.

Authentication Note

Examples marked with:

  • Public - No authentication required (anyone can connect)
  • Authenticated - Requires token verification
  • Authorized - Requires authentication + role/permission checks

For production apps, always use authenticated examples. See Security Guide - Authentication for implementation details.

Legacy Examples

Related Documentation