Skip to content
This repository was archived by the owner on Oct 22, 2025. It is now read-only.

Commit a7cfcbe

Browse files
authored
Merge branch 'rivet-gg:main' into main
2 parents 6370ca8 + 4e3a935 commit a7cfcbe

File tree

97 files changed

+1965
-919
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+1965
-919
lines changed

README.md

Lines changed: 173 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,177 @@
1+
<!--
2+
THIS FILE IS AUTO-GENERATED. DO NOT EDIT DIRECTLY.
3+
To update this README, run: npm run gen:readme in the github.com/rivet-gg/rivet repository
4+
Generated from: github.com/rivet-gg/rivet/site/scripts/generateReadme.mjs
5+
-->
6+
17
<div align="center">
28
<a href="https://rivetkit.org">
39
<picture>
410
<source media="(prefers-color-scheme: dark)" srcset="./.github/media/logo/dark.svg" alt="RivetKit">
5-
<img src="./.github/media/logo/light.svg" alt="RivetKit" width="400">
11+
<img src="./.github/media/logo/light.svg" alt="RivetKit" height="75">
612
</picture>
713
</a>
814
<br/>
915
<br/>
10-
<p><b>Lightweight Libraries for Backends</b></p>
16+
<p><b>The open-source alternative to Durable Objects</b></p>
1117
<p>
12-
Install one package, scale to production.<br/>
13-
<u>Just a library, no SaaS.</u><br/>
18+
RivetKit is a library for long-lived processes with durable state, realtime, and scalability.<br/>
19+
Easily <u>self-hostable</u> and works <u>with your infrastructure</u>.
1420
</p>
1521
<p>
16-
<i>
17-
Supports <a href="https://rivetkit.org/drivers/rivet">Rivet</a>, <a href="https://rivetkit.org/drivers/cloudflare-workers">Cloudflare</a>, <a href="https://rivetkit.org/actors/quickstart-backend">Node</a>, <a href="https://rivetkit.org/actors/quickstart-backend">Bun</a>, <a href="https://rivetkit.org/drivers/redis">Redis</a>, <a href="https://rivetkit.org/drivers/memory">memory</a>, <a href="https://rivetkit.org/drivers/file-system">file system</a>, <a href="https://rivetkit.org/clients/javascript">TypeScript</a>,<br/>
18-
Rust, <a href="https://rivetkit.org/clients/react">React</a>, <a href="https://rivetkit.org/integrations/hono">Hono</a>, <a href="https://rivetkit.org/integrations/express">Express</a>, <a href="https://rivetkit.org/integrations/elysia">Elysia</a>, <a href="https://rivetkit.org/integrations/trpc">tRPC</a>, <a href="https://rivetkit.org/integrations/better-auth">Better Auth</a>, and <a href="https://rivetkit.org/general/testing">Vitest</a>.
19-
</i>
22+
<a href="https://rivet.gg/docs/actors/quickstart">Quickstart</a> •
23+
<a href="https://rivet.gg/docs/actors">Documentation</a> •
24+
<a href="https://rivet.gg/docs/general/self-hosting">Self-Hosting</a> •
25+
<a href="https://rivet.gg/discord">Discord</a> •
26+
<a href="https://x.com/rivet_gg">X</a> •
27+
<a href="https://bsky.app/profile/rivet.gg">Bluesky</a>
2028
</p>
2129
<p>
22-
<a href="https://rivetkit.org/">Documentation</a> •
23-
<a href="https://discord.gg/rivet">Discord</a>
24-
<a href="https://x.com/RivetKit_org">X</a>
25-
<a href="https://bsky.app/">Bluesky</a>
30+
<i>
31+
Supports <a href="https://rivetkit.org/actors/quickstart-backend">Node.js</a>, <a href="https://rivetkit.org/actors/quickstart-backend">Bun</a>, <a href="https://rivetkit.org/drivers/redis">Redis</a>, <a href="https://rivetkit.org/drivers/cloudflare-workers">Cloudflare</a>,<br/>
32+
<a href="https://rivetkit.org/clients/react">React</a>, <a href="https://rivetkit.org/clients/rust">Rust</a>, <a href="https://rivetkit.org/integrations/hono">Hono</a>, <a href="https://rivetkit.org/integrations/express">Express</a>, <a href="https://rivetkit.org/integrations/trpc">tRPC</a>, and <a href="https://rivetkit.org/integrations/better-auth">Better Auth</a>.
33+
</i>
2634
</p>
27-
2835
</div>
2936

30-
## Quickstart
37+
## Projects
3138

32-
- <img src=".github/media/clients/javascript.svg" height="16" alt="Node.js" />&nbsp;&nbsp;[Node.js & Bun](https://rivetkit.org/actors/quickstart-backend)
33-
- <img src=".github/media/clients/react.svg" height="16" alt="React" />&nbsp;&nbsp;[React](https://rivetkit.org/actors/quickstart-react)
39+
Public-facing projects:
3440

35-
## Examples
41+
- **RivetKit** (you are here): Lightweight TypeScript library for building Rivet Actors
42+
- **[Rivet Engine](https://github.com/rivet-gg/rivet)** : Engine that powers Rivet Actors at scale — completely optional
43+
- **[Rivet Studio](https://github.com/rivet-gg/rivet/tree/main/frontend/apps/studio)**: Like Postman, but for Rivet Actors
44+
- **[Rivet Documentation](https://github.com/rivet-gg/rivet/tree/main/site/src/content/docs)**
45+
46+
## Get Started
47+
48+
### Guides
49+
50+
Get started with Rivet by following a quickstart guide:
51+
52+
- [Node.js & Bun](https://www.rivet.gg/docs/actors/quickstart/backend/)
53+
- [React](https://www.rivet.gg/docs/actors/quickstart/react/)
54+
55+
56+
### Quickstart
57+
58+
**Step 1**: Install RivetKit
59+
60+
```sh
61+
npm install @rivetkit/actor
62+
```
63+
64+
**Step 2**: Create an actor
65+
66+
```typescript
67+
// registry.ts
68+
import { actor, setup } from "@rivetkit/actor";
69+
70+
export const counter = actor({
71+
state: { count: 0 },
72+
actions: {
73+
increment: (c, amount: number = 1) => {
74+
// State changes are durable & automatically persisted
75+
c.state.count += amount;
76+
// Broadcast realtime events
77+
c.broadcast("countChanged", c.state.count);
78+
// Return data to client
79+
return c.state.count;
80+
},
81+
getCount: (c) => c.state.count,
82+
},
83+
});
84+
85+
export const registry = setup({
86+
use: { counter },
87+
});
88+
```
89+
90+
Read more about [state](https://www.rivet.gg/docs/actors/state/), [actions](https://www.rivet.gg/docs/actors/actions/), and [events](https://www.rivet.gg/docs/actors/events/).
91+
92+
**Step 2**: Setup server
93+
94+
_Alternatively, see the [React](https://www.rivet.gg/docs/actors/quickstart/react/) guide which does not require a server._
95+
96+
```typescript
97+
// server.ts
98+
import { registry } from "./registry";
99+
import { Hono } from "hono";
36100

37-
Browse snippets for how to use RivetKit with different use cases.
101+
// Start with file system driver for development
102+
const { client, serve } = registry.createServer();
38103

39-
| Example | Actor (JavaScript) | Actor (SQLite) | Frontend (React) |
40-
|---------|------------|--------|-------|
41-
| AI Agent | [actor.ts](/examples/snippets/ai-agent/actor-json.ts) | [actor.ts](/examples/snippets/ai-agent/actor-sqlite.ts) | [App.tsx](/examples/snippets/ai-agent/App.tsx) |
42-
| Collaborative Document (CRDT) | [actor.ts](/examples/snippets/crdt/actor-json.ts) | [actor.ts](/examples/snippets/crdt/actor-sqlite.ts) | [App.tsx](/examples/snippets/crdt/App.tsx) |
43-
| Chat Room | [actor.ts](/examples/snippets/chat-room/actor-json.ts) | [actor.ts](/examples/snippets/chat-room/actor-sqlite.ts) | [App.tsx](/examples/snippets/chat-room/App.tsx) |
44-
| Per-User Databases | [actor.ts](/examples/snippets/database/actor-json.ts) | [actor.ts](/examples/snippets/database/actor-sqlite.ts) | [App.tsx](/examples/snippets/database/App.tsx) |
45-
| Rate Limiter | [actor.ts](/examples/snippets/rate/actor-json.ts) | [actor.ts](/examples/snippets/rate/actor-sqlite.ts) | [App.tsx](/examples/snippets/rate/App.tsx) |
46-
| Stream Processing | [actor.ts](/examples/snippets/stream/actor-json.ts) | [actor.ts](/examples/snippets/stream/actor-sqlite.ts) | [App.tsx](/examples/snippets/stream/App.tsx) |
47-
| Multiplayer Game | [actor.ts](/examples/snippets/game/actor-json.ts) | [actor.ts](/examples/snippets/game/actor-sqlite.ts) | [App.tsx](/examples/snippets/game/App.tsx) |
48-
| Local-First Sync | [actor.ts](/examples/snippets/sync/actor-json.ts) | [actor.ts](/examples/snippets/sync/actor-sqlite.ts) | [App.tsx](/examples/snippets/sync/App.tsx) |
104+
// Setup your server
105+
const app = new Hono();
49106

50-
_SQLite available in July._
107+
app.post("/increment/:name", async (c) => {
108+
const name = c.req.param("name");
51109

52-
## Runs On Your Stack
110+
// Get or create actor with key `name`
111+
const counter = client.counter.getOrCreate(name);
53112

54-
Deploy RivetKit anywhere - from serverless platforms to your own infrastructure. Don't see the runtime you want? [Add your own](https://rivetkit.org/drivers/build).
113+
// Call an action
114+
const newCount = await counter.increment(1);
115+
116+
return c.json({ count: newCount });
117+
});
118+
119+
// Start server with Rivet
120+
serve(app);
121+
```
122+
123+
Start the server with:
124+
125+
```typescript
126+
npx tsx server.ts
127+
// or
128+
bun server.ts
129+
```
130+
131+
Read more about [clients](https://www.rivet.gg/docs/actors/clients/).
132+
133+
You can connect to your server with:
134+
135+
```typescript
136+
// client.ts
137+
const response = await fetch("http://localhost:8080/increment/my-counter", { method: "POST" });
138+
const result = await response.json();
139+
console.log("Count:", result.count); // 1
140+
```
141+
142+
**Step 3**: Deploy
143+
144+
To scale Rivet in production, follow a guide to deploy to a hosting provider or integrate a driver:
145+
146+
- [Redis](https://www.rivet.gg/docs/drivers/redis/)
147+
- [Cloudflare Workers](https://www.rivet.gg/docs/hosting-providers/cloudflare-workers/)
148+
149+
## Features
150+
151+
RivetKit provides everything you need to build fast, scalable, and real-time applications without the complexity.
152+
153+
- **Long-Lived, Stateful Compute**: Like AWS Lambda but with memory and no timeouts
154+
- **Blazing-Fast Reads & Writes**: State stored on same machine as compute
155+
- **Realtime, Made Simple**: Built-in WebSockets and SSE support
156+
- **Store Data Near Your Users**: Deploy to the edge for low-latency access
157+
- **Infinitely Scalable**: Auto-scale from zero to millions without configuration
158+
- **Fault Tolerant**: Automatic error handling and recovery built-in
159+
160+
## Examples
161+
162+
- AI Agent — [GitHub](https://github.com/rivet-gg/rivetkit/tree/main/examples/ai-agent) · [StackBlitz](https://stackblitz.com/github/rivet-gg/rivetkit/tree/main/examples/ai-agent)
163+
- Chat Room — [GitHub](https://github.com/rivet-gg/rivetkit/tree/main/examples/chat-room) · [StackBlitz](https://stackblitz.com/github/rivet-gg/rivetkit/tree/main/examples/chat-room)
164+
- Collab (Yjs) — [GitHub](https://github.com/rivet-gg/rivetkit/tree/main/examples/crdt) · [StackBlitz](https://stackblitz.com/github/rivet-gg/rivetkit/tree/main/examples/crdt)
165+
- Multiplayer Game — [GitHub](https://github.com/rivet-gg/rivetkit/tree/main/examples/game) · [StackBlitz](https://stackblitz.com/github/rivet-gg/rivetkit/tree/main/examples/game)
166+
- Local-First Sync — [GitHub](https://github.com/rivet-gg/rivetkit/tree/main/examples/sync) · [StackBlitz](https://stackblitz.com/github/rivet-gg/rivetkit/tree/main/examples/sync)
167+
- Rate Limiter — [GitHub](https://github.com/rivet-gg/rivetkit/tree/main/examples/rate) · [StackBlitz](https://stackblitz.com/github/rivet-gg/rivetkit/tree/main/examples/rate)
168+
- Per-User DB — [GitHub](https://github.com/rivet-gg/rivetkit/tree/main/examples/database) · [StackBlitz](https://stackblitz.com/github/rivet-gg/rivetkit/tree/main/examples/database)
169+
- Multi-Tenant SaaS — [GitHub](https://github.com/rivet-gg/rivetkit/tree/main/examples/tenant) · [StackBlitz](https://stackblitz.com/github/rivet-gg/rivetkit/tree/main/examples/tenant)
170+
- Stream Processing — [GitHub](https://github.com/rivet-gg/rivetkit/tree/main/examples/stream) · [StackBlitz](https://stackblitz.com/github/rivet-gg/rivetkit/tree/main/examples/stream)
171+
172+
## Runs Anywhere
173+
174+
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://rivetkit.org/drivers/build).
55175

56176
### All-In-One
57177
- <img src=".github/media/platforms/rivet-white.svg" height="16" alt="Rivet" />&nbsp;&nbsp;[Rivet](https://rivetkit.org/drivers/rivet)
@@ -97,19 +217,32 @@ Seamlessly integrate RivetKit with your favorite frameworks, languages, and tool
97217
- <img src=".github/media/integrations/tinybase.svg" height="16" alt="TinyBase" />&nbsp;&nbsp;[TinyBase](https://github.com/rivet-gg/rivetkit/issues/910) *(Help Wanted)*
98218
- <img src=".github/media/integrations/yjs.svg" height="16" alt="Yjs" />&nbsp;&nbsp;[Yjs](https://github.com/rivet-gg/rivetkit/issues/911) *(Help Wanted)*
99219

100-
## Join the Community
220+
## Local Development with the Studio
221+
222+
Rivet Studio is like like Postman, but for all of your stateful serverless needs:
223+
224+
- **Live State Inspection**: View and edit your actor state in real-time as messages are sent and processed
225+
- **REPL**: Debug your actor in real-time - call actions, subscribe to events, and interact directly with your code
226+
- **Connection Inspection**: Monitor active connections with state and parameters for each client
227+
- **Hot Reload Code Changes**: See code changes instantly without restarting - modify and test on the fly
228+
229+
[Visit the Studio →](https://studio.rivet.gg)
230+
231+
![Rivet Studio](.github/media/screenshots/studio/simple.png)
232+
233+
## Community & Support
101234

102-
Help make RivetKit the universal way to build & scale stateful serverless applications.
235+
Join thousands of developers building with RivetKit today:
103236

104-
- [Discord](https://rivet.gg/discord)
105-
- [X](https://x.com/RivetKit_org)
106-
- [Bluesky](https://bsky.app/profile/rivet.gg)
107-
- [Discussions](https://github.com/rivet-gg/rivetkit/discussions)
108-
- [Issues](https://github.com/rivet-gg/rivetkit/issues)
237+
- [Discord](https://rivet.gg/discord) - Chat with the community
238+
- [X/Twitter](https://x.com/rivet_gg) - Follow for updates
239+
- [Bluesky](https://bsky.app/profile/rivet.gg) - Follow for updates
240+
- [GitHub Discussions](https://github.com/rivet-gg/rivetkit/discussions) - Ask questions and share ideas
241+
- [GitHub Issues](https://github.com/rivet-gg/rivetkit/issues) - Report bugs and request features
242+
- [Talk to an engineer](https://rivet.gg/talk-to-an-engineer) - Discuss your technical needs, current stack, and how Rivet can help with your infrastructure challenges
109243

110244
## License
111245

112-
Apache 2.0
246+
[Apache 2.0](LICENSE)
113247

114-
_Performance in every act - thanks to Rivet Actors._
115248

clients/openapi/openapi.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"openapi": "3.0.0",
33
"info": {
4-
"version": "0.9.3",
4+
"version": "0.9.5",
55
"title": "RivetKit API"
66
},
77
"components": {

examples/ai-agent/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "example-ai-agent",
3-
"version": "0.9.3",
3+
"version": "0.9.5",
44
"private": true,
55
"type": "module",
66
"scripts": {

examples/better-auth-external-db/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "example-better-auth-external-db",
3-
"version": "0.9.3",
3+
"version": "0.9.5",
44
"private": true,
55
"type": "module",
66
"scripts": {

examples/chat-room/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "chat-room",
3-
"version": "0.9.3",
3+
"version": "0.9.5",
44
"private": true,
55
"type": "module",
66
"scripts": {

examples/cloudflare-workers-hono/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "example-cloudflare-workers-hono",
3-
"version": "0.9.3",
3+
"version": "0.9.5",
44
"private": true,
55
"type": "module",
66
"scripts": {

examples/cloudflare-workers/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "example-cloudflare-workers",
3-
"version": "0.9.3",
3+
"version": "0.9.5",
44
"private": true,
55
"type": "module",
66
"scripts": {

examples/counter/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "counter",
3-
"version": "0.9.3",
3+
"version": "0.9.5",
44
"private": true,
55
"type": "module",
66
"scripts": {
@@ -9,8 +9,8 @@
99
"test": "vitest run"
1010
},
1111
"devDependencies": {
12-
"@types/node": "^22.13.9",
1312
"@rivetkit/actor": "workspace:*",
13+
"@types/node": "^22.13.9",
1414
"tsx": "^3.12.7",
1515
"typescript": "^5.7.3",
1616
"vitest": "^3.1.1"

examples/counter/scripts/connect.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
/// <reference types="node" />
21
import { createClient } from "@rivetkit/actor/client";
3-
import type { Registry } from "../src/actors/registry";
2+
import type { Registry } from "../src/registry";
43

54
async function main() {
65
const client = createClient<Registry>(
76
process.env.ENDPOINT ?? "http://127.0.0.1:8080",
87
);
98

10-
const counter = (await client.counter.getOrCreate()).connect();
9+
const counter = await client.counter.getOrCreate().connect();
1110

1211
counter.on("newCount", (count: number) => console.log("Event:", count));
1312

@@ -18,6 +17,7 @@ async function main() {
1817
await new Promise((resolve) => setTimeout(resolve, 1000));
1918
}
2019

20+
await new Promise((resolve) => setTimeout(resolve, 10000));
2121
await counter.dispose();
2222
}
2323

examples/counter/src/registry.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import { actor, setup } from "@rivetkit/actor";
22

33
const counter = actor({
4-
state: { count: 0 },
4+
state: {
5+
count: 0,
6+
},
7+
onAuth: () => {
8+
return true;
9+
},
510
actions: {
611
increment: (c, x: number) => {
712
c.state.count += x;
@@ -17,3 +22,5 @@ const counter = actor({
1722
export const registry = setup({
1823
use: { counter },
1924
});
25+
26+
export type Registry = typeof registry;

0 commit comments

Comments
 (0)