Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions site/public/llms-full.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 14 additions & 6 deletions site/src/content/docs/actors/actions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,29 @@ console.log(result); // The value returned by the action
Learn more about [communicating with actors from the frontend](/docs/actors/communicating-between-actors).

</Tab>
<Tab title="Backend (registry.runServer)">
<Tab title="Backend (registry.start)">

```typescript {{"title":"server.ts"}}
import { setup } from "rivetkit";
import { Hono } from "hono";
import { serve } from "@hono/node-server";

const registry = setup({
use: { counter }
});

const { client, serve } = registry.runServer();
const { client } = registry.start();

// Use the client to call actions
const counter = await client.counter.getOrCreate();
const result = await counter.increment(42);
console.log(result);
const app = new Hono();

// Use the client to call actions on a request
app.get("/foo", () => {
const counter = await client.counter.getOrCreate();
const result = await counter.increment(42);
c.text(result);
});

serve(app);
```

Learn more about [communicating with actors from the backend](/docs/actors/communicating-between-actors).
Expand Down
6 changes: 4 additions & 2 deletions site/src/content/docs/actors/clients.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Rivet also supports [React](/docs/clients/react) and [Rust](/docs/clients/rust)

Using the RivetKit client is completely optional. If you prefer to write your own networking logic, you can either:

- Write your own HTTP endpoints and use the client returned from `registry.start` (see below)
- Make HTTP requests directly to the registry (see [OpenAPI spec](/docs/clients/openapi))
- Write your own HTTP endpoints and use the client returned from `registry.runServer` (see below)

## Client Setup

Expand All @@ -25,8 +25,10 @@ There are several ways to create a client for communicating with actors:

```typescript {{"title":"server.ts"}}
import { registry } from "./registry";
import { Hono } from "hono";
import { serve } from "@hono/node-server";

const { client, serve } = registry.createServer();
const { client } = registry.start();

const app = new Hono();

Expand Down
6 changes: 4 additions & 2 deletions site/src/content/docs/actors/fetch-and-websocket-handler.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,9 @@ For more advanced use cases, you can forward requests to actor handlers from you
```typescript
import { Hono } from "hono";
import { registry } from "./registry";
import { serve } from "@hono/node-server";

const { client, serve } = registry.createServer();
const { client } = registry.start();

const app = new Hono();

Expand Down Expand Up @@ -241,9 +242,10 @@ serve(app);
```typescript
import { Hono } from "hono";
import { upgradeWebSocket } from "hono/ws";
import { serve } from "@hono/node-server";
import { registry } from "./registry";

const { client, serve } = registry.createServer();
const { client } = registry.start();

const app = new Hono();

Expand Down
10 changes: 4 additions & 6 deletions site/src/content/docs/actors/quickstart/backend.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ Choose your preferred web framework:
```ts {{"title":"Hono"}}
import { registry } from "./registry";
import { Hono } from "hono";
import { serve } from "@hono/node-server";

// Start Rivet with file system driver (for development)
const { client, serve } = registry.createServer();
const { client } = registry.start();

// Setup Hono app
const app = new Hono();
Expand All @@ -75,15 +76,12 @@ import { registry } from "./registry";
import express from "express";

// Start Rivet
const { client, handler } = registry.createServer();
const { client } = registry.start();

// Setup Express app
const app = express();
app.use(express.json());

// Mount Rivet handler
app.use("/registry", handler);

// Example API endpoints
app.post("/increment/:name", async (req, res) => {
const { name } = req.params;
Expand All @@ -104,7 +102,7 @@ import { registry } from "./registry";
import { Elysia } from "elysia";

// Start Rivet
const { client, handler } = registry.createServer();
const { client } = registry.start();

// Setup Elysia app
const app = new Elysia()
Expand Down
Loading
Loading