Skip to content
Roomful is in public beta — install with the @beta tag. Share feedback →

Recipe: Live Voting

Audience: users.

Goal: synchronize votes in real time with deterministic merge behavior.

Use CRDT-backed shared state for concurrent vote updates.

const poll = room.useState({
initialValue: {
question: 'Which feature should we build next?',
options: ['Mobile app', 'API access', 'Relay auth'],
votes: {} as Record<string, number>,
},
strategy: 'crdt',
});
function vote(userId: string, optionIndex: number) {
const current = poll.get();
poll.set({
...current,
votes: { ...current.votes, [userId]: optionIndex },
});
}
  • Use per-user vote keying to prevent accidental overcount.
  • Derive totals from current vote map.