|
| 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 | + |
1 | 7 | <div align="center"> |
2 | 8 | <a href="https://rivetkit.org"> |
3 | 9 | <picture> |
4 | 10 | <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"> |
6 | 12 | </picture> |
7 | 13 | </a> |
8 | 14 | <br/> |
9 | 15 | <br/> |
10 | | - <p><b>Lightweight Libraries for Backends</b></p> |
| 16 | + <p><b>The open-source alternative to Durable Objects</b></p> |
11 | 17 | <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>. |
14 | 20 | </p> |
15 | 21 | <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> |
20 | 28 | </p> |
21 | 29 | <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> |
26 | 34 | </p> |
27 | | - |
28 | 35 | </div> |
29 | 36 |
|
30 | | -## Quickstart |
| 37 | +## Projects |
31 | 38 |
|
32 | | -- <img src=".github/media/clients/javascript.svg" height="16" alt="Node.js" /> [Node.js & Bun](https://rivetkit.org/actors/quickstart-backend) |
33 | | -- <img src=".github/media/clients/react.svg" height="16" alt="React" /> [React](https://rivetkit.org/actors/quickstart-react) |
| 39 | +Public-facing projects: |
34 | 40 |
|
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"; |
36 | 100 |
|
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(); |
38 | 103 |
|
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(); |
49 | 106 |
|
50 | | -_SQLite available in July._ |
| 107 | +app.post("/increment/:name", async (c) => { |
| 108 | + const name = c.req.param("name"); |
51 | 109 |
|
52 | | -## Runs On Your Stack |
| 110 | + // Get or create actor with key `name` |
| 111 | + const counter = client.counter.getOrCreate(name); |
53 | 112 |
|
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). |
55 | 175 |
|
56 | 176 | ### All-In-One |
57 | 177 | - <img src=".github/media/platforms/rivet-white.svg" height="16" alt="Rivet" /> [Rivet](https://rivetkit.org/drivers/rivet) |
@@ -97,19 +217,32 @@ Seamlessly integrate RivetKit with your favorite frameworks, languages, and tool |
97 | 217 | - <img src=".github/media/integrations/tinybase.svg" height="16" alt="TinyBase" /> [TinyBase](https://github.com/rivet-gg/rivetkit/issues/910) *(Help Wanted)* |
98 | 218 | - <img src=".github/media/integrations/yjs.svg" height="16" alt="Yjs" /> [Yjs](https://github.com/rivet-gg/rivetkit/issues/911) *(Help Wanted)* |
99 | 219 |
|
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 | + |
| 232 | + |
| 233 | +## Community & Support |
101 | 234 |
|
102 | | -Help make RivetKit the universal way to build & scale stateful serverless applications. |
| 235 | +Join thousands of developers building with RivetKit today: |
103 | 236 |
|
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 |
109 | 243 |
|
110 | 244 | ## License |
111 | 245 |
|
112 | | -Apache 2.0 |
| 246 | +[Apache 2.0](LICENSE) |
113 | 247 |
|
114 | | -_Performance in every act - thanks to Rivet Actors._ |
115 | 248 |
|
0 commit comments