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
2 changes: 1 addition & 1 deletion docs/concepts/cors.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { setup } from "rivetkit";
import counter from "./counter";

const registry = setup({
actors: { counter },
use: { counter },
// Change this to match your frontend's origin
cors: { origin: "https://yourdomain.com" }
});
Expand Down
2 changes: 1 addition & 1 deletion docs/concepts/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ import chatRoom from "./chat_room";

// Create the application
const registry = setup({
actors: { chatRoom }
use: { chatRoom }
});

// Start serving on default port
Expand Down
8 changes: 4 additions & 4 deletions docs/concepts/testing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const myActor = actor({
});

export const registry = setup({
actors: { myActor }
use: { myActor }
});

export type Registry = typeof registry;
Expand Down Expand Up @@ -109,7 +109,7 @@ const counter = actor({
});

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

export type Registry = typeof registry;
Expand Down Expand Up @@ -164,7 +164,7 @@ export const chatRoom = actor({

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

// Export type for client type checking
Expand Down Expand Up @@ -225,7 +225,7 @@ const scheduler = actor({
});

export const registry = setup({
actors: { scheduler }
use: { scheduler }
});

export type Registry = typeof registry;
Expand Down
2 changes: 1 addition & 1 deletion docs/integrations/better-auth.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const counter = actor({
});

export const registry = setup({
actors: { counter },
use: { counter },
});
```

Expand Down
8 changes: 4 additions & 4 deletions docs/integrations/hono.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ When mounting the RivetKit router at a custom path, you **must** specify the sam
```typescript
// Setup the RivetKit app
const registry = setup({
actors: { counter },
use: { counter },
// IMPORTANT: Must specify the same basePath where your router is mounted
basePath: "/my-path"
});
Expand Down Expand Up @@ -46,7 +46,7 @@ honoApp.get("/hello", (c) => c.text("Hello, world!"));

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

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

// Setup the RivetKit app
const registry = setup({
actors: { counter },
use: { counter },
// IMPORTANT: Must specify the same basePath where your router is mounted
basePath: "/my-path"
});
Expand Down
2 changes: 1 addition & 1 deletion docs/integrations/resend.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const user = actor({
},
});

export const registry = setup({ actors: { user } });
export const registry = setup({ use: { 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

## Actor Management

- App is configured with actors using `setup({ actors: { actorName }})` followed by `serve(registry)`
- App is configured with actors using `setup({ use: { actorName }})` followed by `serve(registry)`
- Actors are accessed by client using `client.actorName.get()`
- Actors can pass an ID parameter or object with `client.actorName.get(id)` or `client.actorName.get({key: value})`
- Actors can be shut down with `c.shutdown()` from within the actor
Expand Down
2 changes: 1 addition & 1 deletion docs/snippets/setup-actor.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const counter = actor({

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

Expand Down
2 changes: 1 addition & 1 deletion docs/snippets/step-define-actor.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

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

Expand Down
2 changes: 1 addition & 1 deletion docs/workers/actions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const counter = actor({

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

export type Registry = typeof registry;
Expand Down
2 changes: 1 addition & 1 deletion docs/workers/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ import chatRoom from "./chat_room";

// Create the application
const registry = setup({
actors: { chatRoom }
use: { chatRoom }
});

// Start serving on default port
Expand Down
2 changes: 1 addition & 1 deletion docs/workers/quickstart-frontend.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const counter = actor({
});

export const registry = setup({
actors: { counter },
use: { counter },
});
```

Expand Down
2 changes: 1 addition & 1 deletion docs/workers/quickstart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const counter = actor({
});

export const registry = setup({
actors: { counter },
use: { counter },
});
```

Expand Down
2 changes: 1 addition & 1 deletion examples/better-auth/src/backend/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
// });
//
// export const registry = setup({
// actors: { chatRoom },
// use: { chatRoom },
// });
//
// export type Registry = typeof registry;
2 changes: 1 addition & 1 deletion examples/chat-room/src/workers/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const chatRoom = actor({

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

// Export type for client type checking
Expand Down
2 changes: 1 addition & 1 deletion examples/cloudflare-workers/src/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const counter = actor({
});

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

export type Registry = typeof registry;
2 changes: 1 addition & 1 deletion examples/counter/src/workers/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const counter = actor({
});

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

export type Registry = typeof registry;
2 changes: 1 addition & 1 deletion examples/drizzle/src/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// });

// export const registry = setup({
// actors: { counter },
// use: { counter },
// });

// export type Registry = typeof registry;
2 changes: 1 addition & 1 deletion examples/elysia/src/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const counter = actor({
});

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

export type Registry = typeof registry;
2 changes: 1 addition & 1 deletion examples/express/src/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const counter = actor({
});

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

export type Registry = typeof registry;
2 changes: 1 addition & 1 deletion examples/hono-react/src/backend/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const counter = actor({
});

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

export type Registry = typeof registry;
2 changes: 1 addition & 1 deletion examples/hono/src/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const counter = actor({
});

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

export type Registry = typeof registry;
2 changes: 1 addition & 1 deletion examples/react/src/backend/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const counter = actor({
});

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

export type Registry = typeof registry;
2 changes: 1 addition & 1 deletion examples/rivet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"typescript": "^5.5.2"
},
"dependencies": {
"@rivetkit/actor": "workspace:*"
"@rivetkit/actor": "https://pkg.pr.new/rivet-gg/rivetkit/@rivetkit/actor@cb1e6d4"
},
"stableVersion": "0.8.0"
}
1 change: 1 addition & 0 deletions examples/rivet/src/server.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { registry } from "./registry";

console.log("new version");
registry.runServer();
2 changes: 1 addition & 1 deletion examples/trpc/src/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const counter = actor({
});

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

export type Registry = typeof registry;
2 changes: 1 addition & 1 deletion packages/core/fixtures/driver-test-suite/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import {

// Consolidated setup with all actors
export const registry = setup({
actors: {
use: {
// From counter.ts
counter,
// From lifecycle.ts
Expand Down
2 changes: 1 addition & 1 deletion packages/core/scripts/dump-openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { VERSION } from "@/utils";

function main() {
const registryConfig: RegistryConfig = RegistryConfigSchema.parse({
actors: {},
use: {},
});
const registry = setup(registryConfig);

Expand Down
16 changes: 8 additions & 8 deletions packages/core/src/client/actor-conn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,18 +255,18 @@ enc
signal ? { signal } : undefined,
);
this.#transport = { websocket: ws };
ws.onopen = () => {
ws.addEventListener("open", () => {
logger().debug("websocket open");
};
ws.onmessage = async (ev) => {
});
ws.addEventListener("message", async (ev) => {
this.#handleOnMessage(ev.data);
};
ws.onclose = (ev) => {
});
ws.addEventListener("close", (ev) => {
this.#handleOnClose(ev);
};
ws.onerror = (ev) => {
});
ws.addEventListener("error", (ev) => {
this.#handleOnError();
};
});
}

async #connectSse({ signal }: { signal?: AbortSignal } = {}) {
Expand Down
16 changes: 8 additions & 8 deletions packages/core/src/drivers/rivet/ws-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export async function createWebSocketProxy(
targetWs = new WebSocket(targetUrl, { headers });

// Set up target websocket handlers
targetWs.onopen = () => {
targetWs.addEventListener("open", () => {
invariant(targetWs, "targetWs does not exist");

// Process any queued messages once connected
Expand All @@ -37,13 +37,13 @@ export async function createWebSocketProxy(
// Clear the queue after sending
messageQueue.length = 0;
}
};
});

targetWs.onmessage = (event: any) => {
targetWs.addEventListener("message", (event: any) => {
wsContext.send(event.data as any);
};
});

targetWs.onclose = (event: any) => {
targetWs.addEventListener("close", (event: any) => {
logger().debug("target websocket closed", {
code: event.code,
reason: event.reason,
Expand All @@ -53,17 +53,17 @@ export async function createWebSocketProxy(
// Forward the close code and reason from target to client
wsContext.close(event.code, event.reason);
}
};
});

targetWs.onerror = () => {
targetWs.addEventListener("error", () => {
logger().warn("target websocket error");

if (wsContext.readyState === WebSocket.OPEN) {
// Use standard WebSocket error code: 1006 - Abnormal Closure
// The connection was closed abnormally, e.g., without sending or receiving a Close control frame
wsContext.close(1006, "Error in target connection");
}
};
});
},

// Handle messages from client to target
Expand Down
Loading
Loading