examples/chat-room-effect/README.md
Example project demonstrating a real-time chat room built with the Effect SDK for Rivet Actors.
git clone https://github.com/rivet-dev/rivet.git
cd rivet/examples/chat-room-effect
npm install
npm run dev
In a separate terminal, run a client against the server:
npm run client # Effect client
npm run client:raw # plain RivetKit client
Actor.make and implement them with toLayer, composing actor logic from Effect Layers and servicesAction.make values with effect/Schema payloads, successes, and errors validated end to endMemberNotInRoomError and BannedWordsError flow through the action error channel and are caught by tag on the clientChatRoom actor calls a separate Moderator actor to screen messages, using the same client API as client-to-actor callsThe example splits each actor into a public contract and a server-only implementation:
src/actors/chat-room/api.ts): Declares the ChatRoom actor, its actions, and its typed errorssrc/actors/chat-room/live.ts): Implements the wake scope, state schema, SQLite migration, and action handlerssrc/actors/moderator/api.ts, live.ts): A second actor that screens messages for banned wordssrc/main.ts): Composes the actor layers and serves them with Registry.servesrc/client.ts, src/client-raw.ts): An Effect client using the typed ChatRoom.client accessor, and a plain RivetKit client showing the same actors reached from non-Effect codeRead more about actions, state, events, and the Effect quickstart.
MIT