Skip to main content
← Back to Templates

Per-Tenant Database

Example project demonstrating per-company database isolation with Rivet Actor state.

Per-Tenant Database

Features

  • Per-tenant isolation: Each company name maps to its own CompanyDatabase actor and state
  • State as the database: Employees and projects live in c.state for every actor instance
  • Action-driven updates: Add and list data through actions like addEmployee and listProjects
  • Live switching: Swap company names in the UI to see fully isolated datasets

Implementation

The dashboard connects to one CompanyDatabase actor per company. The actor key is the company name, and its state becomes that company database.

See the implementation in src/actors.ts and frontend/App.tsx.

Resources

Read more about state, actions, and events.