Skip to content
This repository was archived by the owner on Oct 22, 2025. It is now read-only.
Closed
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
6 changes: 3 additions & 3 deletions docs/concepts/cors.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ Cross-Origin Resource Sharing (CORS) is a security mechanism that allows a web a

You'll need to configure CORS when:

- **Local Development:** You're developing locally and your client runs on a different port than your worker service
- **Different Domain:** Your frontend application is hosted on a different domain than your worker service
- **Local Development**: You're developing locally and your client runs on a different port than your worker service
- **Different Domain**: Your frontend application is hosted on a different domain than your worker service

## Example

```ts
import { setup } from "rivetkit";
import counter from "./counter";

const app = setup({
const registry = setup({
workers: { counter },
// Change this to match your frontend's origin
cors: { origin: "https://yourdomain.com" }
Expand Down
6 changes: 3 additions & 3 deletions docs/concepts/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ import { setup, serve } from "rivetkit";
import chatRoom from "./chat_room";

// Create the application
const app = setup({
const registry = setup({
workers: { chatRoom }
});

// Start serving on default port
serve(app);
serve(registry);

// Export the app type for client usage
export type App = typeof app;
export type Registry = typeof registry;
```

## Key Worker Components
Expand Down
16 changes: 8 additions & 8 deletions docs/concepts/testing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ const myWorker = worker({
}
});

export const app = setup({
export const registry = setup({
workers: { myWorker }
});

export type App = typeof app;
export type Registry = typeof registry;
```
</CodeGroup>

Expand Down Expand Up @@ -108,11 +108,11 @@ const counter = worker({
}
});

export const app = setup({
export const registry = setup({
workers: { counter }
});

export type App = typeof app;
export type Registry = typeof registry;
```
</CodeGroup>

Expand Down Expand Up @@ -163,12 +163,12 @@ export const chatRoom = worker({
});

// Create and export the app
export const app = setup({
export const registry = setup({
workers: { chatRoom }
});

// Export type for client type checking
export type App = typeof app;
export type Registry = typeof registry;
```
</CodeGroup>

Expand Down Expand Up @@ -224,11 +224,11 @@ const scheduler = worker({
}
});

export const app = setup({
export const registry = setup({
workers: { scheduler }
});

export type App = typeof app;
export type Registry = typeof registry;
```
</CodeGroup>

Expand Down
14 changes: 7 additions & 7 deletions docs/integrations/hono.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ When mounting the RivetKit router at a custom path, you **must** specify the sam

```typescript
// Setup the RivetKit app
const app = setup({
const registry = setup({
workers: { counter },
// IMPORTANT: Must specify the same basePath where your router is mounted
basePath: "/my-path"
Expand Down Expand Up @@ -45,7 +45,7 @@ honoApp.get("/", (c) => c.text("Welcome to my app!"));
honoApp.get("/hello", (c) => c.text("Hello, world!"));

// Setup the RivetKit app
const app = setup({
const registry = setup({
workers: { counter },
// IMPORTANT: Must specify the same basePath where your router is mounted
basePath: "/my-path"
Expand All @@ -58,7 +58,7 @@ const { router: workerRouter, WorkerHandler } = createRouter(app);
honoApp.route("/my-path", workerRouter);

// Export the app type for client usage
export type App = typeof app;
export type Registry = typeof registry;

// IMPORTANT: Must export `WorkerHandler` as this exact name
export { honoApp as default, WorkerHandler };
Expand Down Expand Up @@ -121,7 +121,7 @@ honoApp.get("/", (c) => c.text("Welcome to my app!"));
honoApp.get("/hello", (c) => c.text("Hello, world!"));

// Setup the RivetKit app
const app = setup({
const registry = setup({
workers: { counter },
// IMPORTANT: Must specify the same basePath where your router is mounted
basePath: "/my-path"
Expand All @@ -134,7 +134,7 @@ const { router: workerRouter, injectWebSocket } = createRouter(app);
honoApp.route("/my-path", workerRouter);

// Export the app type for client usage
export type App = typeof app;
export type Registry = typeof registry;

// Create server with the combined app
const server = serve({
Expand Down Expand Up @@ -173,7 +173,7 @@ honoApp.get("/", (c) => c.text("Welcome to my app!"));
honoApp.get("/hello", (c) => c.text("Hello, world!"));

// Setup the RivetKit app
const app = setup({
const registry = setup({
workers: { counter },
// IMPORTANT: Must specify the same basePath where your router is mounted
basePath: "/my-path"
Expand All @@ -186,7 +186,7 @@ const { router: workerRouter, webSocketHandler } = createRouter(app);
honoApp.route("/my-path", workerRouter);

// Export the app type for client usage
export type App = typeof app;
export type Registry = typeof registry;

// Create and start the server
export default {
Expand Down
4 changes: 2 additions & 2 deletions docs/integrations/resend.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ const user = worker({
},
});

export const app = setup({ workers: { user } });
export type App = typeof app;
export const registry = setup({ workers: { user } });
export type Registry = typeof registry;
```
</Step>

Expand Down
2 changes: 1 addition & 1 deletion docs/llm/prompt.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ When importing from workspace packages, always check the package's `package.json

## Worker Management

- App is configured with workers using `setup({ workers: { workerName }})` followed by `serve(app)`
- App is configured with workers using `setup({ workers: { workerName }})` followed by `serve(registry)`
- Workers are accessed by client using `client.workerName.get()`
- Workers can pass an ID parameter or object with `client.workerName.get(id)` or `client.workerName.get({key: value})`
- Workers can be shut down with `c.shutdown()` from within the worker
Expand Down
2 changes: 1 addition & 1 deletion docs/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -325,4 +325,4 @@
}
}
}
}
}
2 changes: 1 addition & 1 deletion docs/platforms/bun.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Bun provides a fast runtime environment for running RivetKit, with excellent per
import { app } from "../workers/app";

// Start the server with file-system driver (default)
serve(app);
serve(registry);
```
</Step>

Expand Down
2 changes: 1 addition & 1 deletion docs/platforms/nodejs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Node.js provides a robust environment for running RivetKit, ideal for developmen
import { app } from "../workers/app";

// Start the server with file-system driver (default)
serve(app);
serve(registry);
```
</Step>

Expand Down
4 changes: 2 additions & 2 deletions docs/snippets/setup-actor.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ const counter = worker({
});

// Create the application
export const app = setup({
export const registry = setup({
workers: { counter },
cors: { origin: "http://localhost:8080" }
});

// Export app type for client usage
export type App = typeof app;
export type Registry = typeof registry;
```

4 changes: 2 additions & 2 deletions docs/snippets/step-define-actor.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
});

// Create the application
export const app = setup({
export const registry = setup({
workers: { counter },
cors: { origin: "*" } // Configure CORS for your production domains in production
});

// Export app type for client usage
export type App = typeof app;
export type Registry = typeof registry;
```
</Step>
4 changes: 2 additions & 2 deletions docs/workers/actions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ const counter = worker({
});

// Create and export the app
const app = setup({
const registry = setup({
workers: { counter }
});

export type App = typeof app;
export type Registry = typeof registry;
```

```typescript client.ts
Expand Down
8 changes: 4 additions & 4 deletions docs/workers/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ import { setup, serve } from "rivetkit";
import chatRoom from "./chat_room";

// Create the application
const app = setup({
const registry = setup({
workers: { chatRoom }
});

// Start serving on default port
serve(app);
serve(registry);

// Export the app type for client usage
export type App = typeof app;
export type Registry = typeof registry;
```

## Key Worker Components
Expand Down Expand Up @@ -278,4 +278,4 @@ Learn more about Rivet Workers:
<Card title="Schedule" icon="clock" href="/worker/schedule">
Schedule tasks and alarms with workers for time-based operations.
</Card>
</CardGroup>
</CardGroup>
54 changes: 50 additions & 4 deletions docs/workers/quickstart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,52 @@ icon: forward
description: Start building awesome documentation in under 5 minutes
---

```ts registry.ts
import { setup } from "rivetkit";
import { worker } from "rivetkit/worker";
import { workflow } from "rivetkit/workflow";
import { realtime } from "rivetkit/realtime";

const counter = worker({
state: {
count: 0,
},
actions: {
foo: (c) => c.state.count++,
},
});

const myWorkflow = workflow({
run: () => {}
});

const myRealtime = realtime({
run: () => {}
});

const registry = setup({
registry: { counter, myWorkflow, myRealtime },
maxConnParamLength: 123
});

export type Registry = typeof registry;
```

```ts server.ts
import { registry } from "./registry";

const registry = new Hono();
app.route("/registry", registry.handler);
serve(registry);
```

```ts client.ts
import { createClient } from "rivetkit/client";
import type { Registry } from "./registry";

const client = createClient<Registry>("http://localhost:8080/registry");
```

<Steps>
<Step title="Install">

Expand Down Expand Up @@ -51,15 +97,15 @@ const myWorker = worker({
<CodeGroup>

```ts Hono
const app = new Hono();
const registry = new Hono();
app.route("rivetkit", setup({ myWf, myWorker }));
serve(app);
serve(registry);
```

```ts Express.js
const app = new Hono();
const registry = new Hono();
app.route("rivetkit", setup({ myWf, myWorker }));
serve(app);
serve(registry);
```

</CodeGroup>
Expand Down
4 changes: 2 additions & 2 deletions examples/chat-room-python/src/server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { serve } from "@rivetkit/nodejs";
import { app } from "./workers/app";
import { registry } from "./workers/registry";

serve(app);
serve(registry);
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ export const chatRoom = worker({
});

// Create and export the app
export const app = setup({
export const registry = setup({
workers: { chatRoom },
});

// Export type for client type checking
export type App = typeof app;
export type Registry = typeof registry;
4 changes: 2 additions & 2 deletions examples/chat-room/scripts/cli.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { createClient } from "rivetkit/client";
import type { App } from "../actors/app";
import type { Registry } from "../workers/registry";
import prompts from "prompts";

async function main() {
const { username, room } = await initPrompt();

// Create type-aware client
const client = createClient<App>("http://localhost:6420");
const client = createClient<Registry>("http://localhost:6420");

// connect to chat room - now accessed via property
// can still pass parameters like room
Expand Down
4 changes: 2 additions & 2 deletions examples/chat-room/scripts/connect.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/// <reference types="node" />
import { createClient } from "rivetkit/client";
import type { App } from "../actors/app";
import type { Registry } from "../workers/registry";

async function main() {
// Create type-aware client
const client = createClient<App>(process.env.ENDPOINT ?? "http://localhost:6420");
const client = createClient<Registry>(process.env.ENDPOINT ?? "http://localhost:6420");

// connect to chat room - now accessed via property
const chatRoom = client.chatRoom.getOrCreate().connect();
Expand Down
Loading
Loading