https://github.com/rivet-dev/rivetkit
A library for building stateful workloads anywhere
https://github.com/rivet-dev/rivetkit
actor actors agents ai ai-agents bun bunjs cloudflare-durable-objects cloudflare-workers durable-objects nodejs rivet supabase typescript vercel
Last synced: about 2 months ago
JSON representation
A library for building stateful workloads anywhere
- Host: GitHub
- URL: https://github.com/rivet-dev/rivetkit
- Owner: rivet-dev
- License: apache-2.0
- Created: 2024-02-07T01:06:25.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-09-16T03:25:22.000Z (2 months ago)
- Last Synced: 2025-09-16T05:41:08.480Z (2 months ago)
- Topics: actor, actors, agents, ai, ai-agents, bun, bunjs, cloudflare-durable-objects, cloudflare-workers, durable-objects, nodejs, rivet, supabase, typescript, vercel
- Language: TypeScript
- Homepage: https://www.rivet.dev
- Size: 33.5 MB
- Stars: 1,148
- Watchers: 6
- Forks: 37
- Open Issues: 59
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Agents: AGENTS.md
Awesome Lists containing this project
- awesome-repositories - rivet-dev/rivetkit - An open-source library for long-lived processes with realtime, persistence, and hibernation (Others)
- awesome - rivet-dev/rivetkit - An open-source library for long-lived processes with realtime, persistence, and hibernation (miscellaneous)
README
The open-source alternative to Durable Objects
RivetKit is a library for long-lived processes with durable state, realtime, and scalability.
Easily self-hostable and works with your infrastructure.
Quickstart •
Documentation •
Self-Hosting •
Discord •
X •
Bluesky
Supports Node.js, Bun, Cloudflare,
React, Rust, Hono, Express, tRPC, and Better Auth.
## Projects
Public-facing projects:
- **RivetKit** (you are here): Lightweight TypeScript library for building Rivet Actors
- **[Rivet Engine](https://github.com/rivet-dev/rivet)** : Engine that powers Rivet Actors at scale — completely optional
- **[Rivet Studio](https://github.com/rivet-dev/rivet/tree/main/frontend/apps/studio)**: Like Chrome DevTools, but for Rivet Actors
- **[Rivet Documentation](https://github.com/rivet-dev/rivet/tree/main/site/src/content/docs)**
## Get Started
### Guides
Get started with Rivet by following a quickstart guide:
- [Node.js & Bun](https://www.rivet.dev/docs/actors/quickstart/backend/)
- [React](https://www.rivet.dev/docs/actors/quickstart/react/)
### Quickstart
**Step 1**: Install RivetKit
```sh
npm install rivetkit
```
**Step 2**: Create an actor
```typescript
// registry.ts
import { actor, setup } from "rivetkit";
export const counter = actor({
state: { count: 0 },
actions: {
increment: (c, amount: number = 1) => {
// State changes are durable & automatically persisted
c.state.count += amount;
// Broadcast realtime events
c.broadcast("countChanged", c.state.count);
// Return data to client
return c.state.count;
},
getCount: (c) => c.state.count,
},
});
export const registry = setup({
use: { counter },
});
```
Read more about [state](https://rivet.dev/docs/actors/state/), [actions](https://rivet.dev/docs/actors/actions/), and [events](https://rivet.dev/docs/actors/events/).
**Step 2**: Setup server
_Alternatively, see the [React](https://rivet.dev/docs/actors/quickstart/react/) guide which does not require a server._
```typescript
// server.ts
import { registry } from "./registry";
import { Hono } from "hono";
// Start with file system driver for development
const { client, serve } = registry.createServer();
// Setup your server
const app = new Hono();
app.post("/increment/:name", async (c) => {
const name = c.req.param("name");
// Get or create actor with key `name`
const counter = client.counter.getOrCreate(name);
// Call an action (with full type safety)
const newCount = await counter.increment(1);
return c.json({ count: newCount });
});
// Start server with Rivet
serve(app);
```
Start the server with:
```typescript
npx tsx server.ts
// or
bun server.ts
```
Read more about [clients](https://rivet.dev/docs/actors/clients/).
You can connect to your server with:
```typescript
// client.ts
const response = await fetch("http://localhost:8080/increment/my-counter", { method: "POST" });
const result = await response.json();
console.log("Count:", result.count); // 1
```
**Step 3**: Deploy
To scale Rivet in production, see [self-hosting documentation](https://www.rivet.dev/docs/self-hosting/).
## Features
RivetKit provides everything you need to build fast, scalable, and real-time applications without the complexity.
- **Long-Lived, Stateful Compute**: Like AWS Lambda but with memory and no timeouts
- **Blazing-Fast Reads & Writes**: State stored on same machine as compute
- **Realtime, Made Simple**: Built-in WebSockets and SSE support
- **Store Data Near Your Users**: Deploy to the edge for low-latency access
- **Infinitely Scalable**: Auto-scale from zero to millions without configuration
- **Fault Tolerant**: Automatic error handling and recovery built-in
## Examples
- AI Agent — [GitHub](https://github.com/rivet-dev/rivetkit/tree/main/examples/ai-agent) · [StackBlitz](https://stackblitz.com/github/rivet-dev/rivetkit/tree/main/examples/ai-agent)
- Chat Room — [GitHub](https://github.com/rivet-dev/rivetkit/tree/main/examples/chat-room) · [StackBlitz](https://stackblitz.com/github/rivet-dev/rivetkit/tree/main/examples/chat-room)
- Collab (Yjs) — [GitHub](https://github.com/rivet-dev/rivetkit/tree/main/examples/crdt) · [StackBlitz](https://stackblitz.com/github/rivet-dev/rivetkit/tree/main/examples/crdt)
- Multiplayer Game — [GitHub](https://github.com/rivet-dev/rivetkit/tree/main/examples/game) · [StackBlitz](https://stackblitz.com/github/rivet-dev/rivetkit/tree/main/examples/game)
- Local-First Sync — [GitHub](https://github.com/rivet-dev/rivetkit/tree/main/examples/sync) · [StackBlitz](https://stackblitz.com/github/rivet-dev/rivetkit/tree/main/examples/sync)
- Rate Limiter — [GitHub](https://github.com/rivet-dev/rivetkit/tree/main/examples/rate) · [StackBlitz](https://stackblitz.com/github/rivet-dev/rivetkit/tree/main/examples/rate)
- Per-User DB — [GitHub](https://github.com/rivet-dev/rivetkit/tree/main/examples/database) · [StackBlitz](https://stackblitz.com/github/rivet-dev/rivetkit/tree/main/examples/database)
- Multi-Tenant SaaS — [GitHub](https://github.com/rivet-dev/rivetkit/tree/main/examples/tenant) · [StackBlitz](https://stackblitz.com/github/rivet-dev/rivetkit/tree/main/examples/tenant)
- Stream Processing — [GitHub](https://github.com/rivet-dev/rivetkit/tree/main/examples/stream) · [StackBlitz](https://stackblitz.com/github/rivet-dev/rivetkit/tree/main/examples/stream)
## Runs Anywhere
Deploy RivetKit anywhere - from serverless platforms to your own infrastructure with RivetKit's flexible runtime options. Don't see the runtime you want? [Add your own](https://rivet.dev/docs/drivers/build-your-own/).
### All-In-One
-
[Rivet](https://rivet.dev/docs/hosting-providers/rivet-cloud/)
-
[Cloudflare Workers](https://rivet.dev/docs/hosting-providers/cloudflare-workers/)
### Compute
-
[Vercel](https://github.com/rivet-dev/rivetkit/issues/897) *(On The Roadmap)*
-
[AWS Lambda](https://github.com/rivet-dev/rivetkit/issues/898) *(On The Roadmap)*
-
[Supabase](https://github.com/rivet-dev/rivetkit/issues/905) *(Help Wanted)*
-
[Bun](https://rivet.dev/docs/actors/quickstart/backend/)
-
[Node.js](https://rivet.dev/docs/actors/quickstart/backend/)
### Storage
-
[Postgres](https://github.com/rivet-dev/rivetkit/issues/899) *(Help Wanted)*
-
[File System](https://rivet.dev/docs/drivers/file-system/)
-
[Memory](https://rivet.dev/docs/drivers/memory/)
## Works With Your Tools
Seamlessly integrate RivetKit with your favorite frameworks, languages, and tools. Don't see what you need? [Request an integration](https://github.com/rivet-dev/rivetkit/issues/new).
### Frameworks
-
[React](https://rivet.dev/docs/clients/react/)
-
[Next.js](https://rivet.dev/docs/clients/nextjs/)
-
[Vue](https://github.com/rivet-dev/rivetkit/issues/903) *(Help Wanted)*
### Clients
-
[JavaScript](https://rivet.dev/docs/clients/javascript/)
-
[TypeScript](https://rivet.dev/docs/clients/javascript/)
-
[Python](https://github.com/rivet-dev/rivetkit/issues/902) *(Help Wanted)*
-
[Rust](https://rivet.dev/docs/clients/rust/)
### Integrations
-
[Hono](https://rivet.dev/docs/integrations/hono/)
-
[Vitest](https://rivet.dev/docs/integrations/vitest/)
-
[Better Auth](https://rivet.dev/docs/integrations/better-auth/)
-
[AI SDK](https://github.com/rivet-dev/rivetkit/issues/907) *(On The Roadmap)*
### Local-First Sync
-
[LiveStore](https://github.com/rivet-dev/rivetkit/issues/908) *(Available In August)*
-
[ZeroSync](https://github.com/rivet-dev/rivetkit/issues/909) *(Help Wanted)*
-
[TinyBase](https://github.com/rivet-dev/rivetkit/issues/910) *(Help Wanted)*
-
[Yjs](https://github.com/rivet-dev/rivetkit/issues/911) *(Help Wanted)*
## Local Development with the Rivet Inspector
Rivet Inspector is like like Chrome DevTools, but for all of your stateful serverless needs. [Visit the Inspector →](https://inspect.rivet.dev)
- **Live State Inspection**: View and edit your actor state in real-time as messages are sent and processed
- **REPL**: Debug your actor in real-time - call actions, subscribe to events, and interact directly with your code
- **Connection Inspection**: Monitor active connections with state and parameters for each client
- **Hot Reload Code Changes**: See code changes instantly without restarting - modify and test on the fly

## Community & Support
Join thousands of developers building with RivetKit today:
- [Discord](https://rivet.dev/discord) - Chat with the community
- [X/Twitter](https://x.com/rivet_gg) - Follow for updates
- [Bluesky](https://bsky.app/profile/rivet.gg) - Follow for updates
- [GitHub Discussions](https://github.com/rivet-dev/rivetkit/discussions) - Ask questions and share ideas
- [GitHub Issues](https://github.com/rivet-dev/rivetkit/issues) - Report bugs and request features
- [Talk to an engineer](https://rivet.dev/talk-to-an-engineer) - Discuss your technical needs, current stack, and how Rivet can help with your infrastructure challenges
## License
[Apache 2.0](LICENSE)