Back to Rivet

Raw WebSocket Handler Proxy

examples/raw-websocket-handler-proxy-vercel/README.md

2.2.11.6 KB
Original Source

Note: This is the Vercel-optimized version of the raw-websocket-handler-proxy example. It uses the hono/vercel adapter and is configured for Vercel deployment.

Raw WebSocket Handler Proxy

Demonstrates raw WebSocket handling using a proxy endpoint pattern for routing connections to actors.

Getting Started

sh
git clone https://github.com/rivet-dev/rivet.git
cd rivet/examples/raw-websocket-handler-proxy
npm install
npm run dev

Features

  • Raw WebSocket handlers: Use onWebSocket for low-level WebSocket control and custom protocols
  • Proxy endpoint pattern: Route WebSocket connections through a proxy endpoint to actors
  • Connection management: Track WebSocket connections with state and broadcasting
  • Real-time chat: Message broadcasting with user presence and chat history
  • Persistent state: Messages and user data automatically saved in actor state

Implementation

This example demonstrates routing WebSocket connections through a proxy:

Resources

Read more about WebSockets, state, and events.

License

MIT