GitHub 37
Skip to content
ViteHub is still experimental. Expect bugs and breaking changes.

Realtime collaboration

Let several people edit one document at the same time, with live changes and automatic saves to a file.

Deploys on
  • Node
  • Docker
  • Cloudflare
server/realtime/docs.tsSame on every host
import { defineRealtime } from 'vite-hub/realtime'

// This file defines the docs room.
export default defineRealtime({
  // Only signed-in users can read and edit
  authorize: true,
  // Save each document to the docs Workspace
  document: { workspace: 'docs' },
  // Let the editor save a version on request
  history: {
    checkpoint: { message: 'Save document' },
  },
})
server/realtime/docs.ts
Deploy on

Node / Docker: Postgres or Redis

One file defines a room

Create a file in server/realtime. Your editor connects by file name.

Works with your TipTap editor

useRealtimeTiptap() gives your TipTap editor live sync and its connection state.

See who is editing

Each person gets a name and a color. Everyone else sees their cursor.

Presence parts in @vite-hub/ui

Pass people, status, and save state straight into the avatar stack and status UI parts.

Saves on its own

Edits save 2 seconds after typing stops and when the last person leaves.

Decide who can join

authorize: true allows only signed-in people. authorize() decides who reads or edits each document.

Runs on Node or Cloudflare

Node instances share rooms over Postgres or Redis. Cloudflare runs rooms in a SQLite-backed Durable Object.

Content documents edit live

With Realtime on, Content adds a content definition for your own live editor: carets, field focus, and drafts that save themselves.