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 handlerpresence-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
- Basic Chat Room - Simple chat room example
- Socket.io-like API - Event handlers and emit API
- Channels - Custom WebSocket paths and multiple channels
- User Presence - Track who is online
- State Persistence - Persist room state across hibernation
- Authentication - JWT token verification
- Rate Limiting - Prevent spam with rate limits
- RPC - Send messages via Remote Procedure Calls
Related Documentation
- Quick Start Guide - Step-by-step tutorial
- API Reference - Complete API documentation
- Security Guide - Authentication and security