Back to Rivet

Geo-Distributed Database

examples/geo-distributed-database-vercel/README.md

2.2.11.8 KB
Original Source

Note: This is the Vercel-optimized version of the geo-distributed-database example. It uses the hono/vercel adapter and is configured for Vercel deployment.

Geo-Distributed Database

Store user session state in edge-local Rivet Actors so preferences and activity stay close to users.

Getting Started

sh
git clone https://github.com/rivet-dev/rivet.git
cd rivet/examples/geo-distributed-database
npm install
npm run dev

Features

  • Creates a region-specific Rivet Actor using createInRegion and createState input.
  • Persists session preferences, recent activity, and last login time in actor state.
  • Measures action latency to highlight the benefit of edge-local updates.
  • Visualizes data locality with a world map and region indicators.

Implementation

The UserSession actor initializes state with a region input and stores session data in persistent state. See the implementation in src/actors.ts.

The frontend connects with createInRegion and displays session locality from the actor state. See the client UI in frontend/App.tsx and the server wiring in src/server.ts.

Resources

Read more about state, actions, and actor inputs.

License

MIT