Skip to content
This repository was archived by the owner on Oct 22, 2025. It is now read-only.
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
769 changes: 217 additions & 552 deletions clients/openapi/openapi.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion examples/ai-agent/src/backend/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export type Message = {
};

export const aiAgent = actor({
onAuth: () => {},
// Persistent state that survives restarts: https://rivet.gg/docs/actors/state
state: {
messages: [] as Message[],
Expand Down
14 changes: 0 additions & 14 deletions examples/better-auth-external-db/src/backend/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,6 @@ interface Message {
}

export const chatRoom = actor({
// onAuth runs on the server & before connecting to the actor
onAuth: async (opts: OnAuthOptions) => {
// Access Better Auth session
const authResult = await auth.api.getSession({
headers: opts.request.headers,
});
if (!authResult) throw new Unauthorized();

// Passes auth data to the actor (c.conn.auth)
return {
user: authResult.user,
session: authResult.session,
};
},
state: {
messages: [],
} as State,
Expand Down
1 change: 0 additions & 1 deletion examples/chat-room/src/backend/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { actor, setup } from "rivetkit";
export type Message = { sender: string; text: string; timestamp: number };

export const chatRoom = actor({
onAuth: () => {},
// Persistent state that survives restarts: https://rivet.gg/docs/actors/state
state: {
messages: [] as Message[],
Expand Down
3 changes: 0 additions & 3 deletions examples/cloudflare-workers-hono/src/registry.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { actor, setup } from "rivetkit";

export const counter = actor({
onAuth: () => {
// Configure auth here
},
state: { count: 0 },
actions: {
increment: (c, x: number) => {
Expand Down
3 changes: 0 additions & 3 deletions examples/cloudflare-workers/src/registry.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { actor, setup } from "rivetkit";

export const counter = actor({
onAuth: () => {
// Configure auth here
},
state: { count: 0, connectionCount: 0, messageCount: 0 },
actions: {
increment: (c, x: number) => {
Expand Down
29 changes: 20 additions & 9 deletions examples/counter/scripts/connect.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,35 @@
import { createClient } from "rivetkit/client";
import type { Registry } from "../src/registry";

async function main() {
const client = createClient<Registry>(
process.env.ENDPOINT ?? "http://127.0.0.1:8080",
);
// async function main() {
// const client = createClient<Registry>();
//
// const counter = await client.counter.getOrCreate().connect();
//
// counter.on("newCount", (count: number) => console.log("Event:", count));
//
// for (let i = 0; i < 5; i++) {
// const out = await counter.increment(5);
// console.log("RPC:", out);
//
// await new Promise((resolve) => setTimeout(resolve, 1000));
// }
//
// await new Promise((resolve) => setTimeout(resolve, 10000));
// await counter.dispose();
// }

const counter = await client.counter.getOrCreate().connect();
async function main() {
const client = createClient<Registry>();

counter.on("newCount", (count: number) => console.log("Event:", count));
const counter = await client.counter.getOrCreate();

for (let i = 0; i < 5; i++) {
const out = await counter.increment(5);
console.log("RPC:", out);

await new Promise((resolve) => setTimeout(resolve, 1000));
}

await new Promise((resolve) => setTimeout(resolve, 10000));
await counter.dispose();
}

main();
3 changes: 0 additions & 3 deletions examples/counter/src/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ const counter = actor({
state: {
count: 0,
},
onAuth: () => {
return true;
},
actions: {
increment: (c, x: number) => {
c.state.count += x;
Expand Down
1 change: 0 additions & 1 deletion examples/crdt/src/backend/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import * as Y from "yjs";
import { applyUpdate, encodeStateAsUpdate } from "yjs";

export const yjsDocument = actor({
onAuth: () => {},
// Persistent state that survives restarts: https://rivet.gg/docs/actors/state
state: {
docData: "", // Base64 encoded Yjs document
Expand Down
1 change: 0 additions & 1 deletion examples/database/src/backend/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { authenticate } from "./my-utils";
export type Note = { id: string; content: string; updatedAt: number };

export const notes = actor({
onAuth: () => {},
// Persistent state that survives restarts: https://rivet.gg/docs/actors/state
state: {
notes: [] as Note[],
Expand Down
3 changes: 0 additions & 3 deletions examples/drizzle/src/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
// state: {
// count: 0,
// },
// onAuth: () => {
// // Configure auth here
// },
// actions: {
// increment: (c, x: number) => {
// // createState or state fix fix fix
Expand Down
3 changes: 0 additions & 3 deletions examples/elysia/src/registry.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { actor, setup } from "rivetkit";

export const counter = actor({
onAuth: () => {
// Configure auth here
},
state: { count: 0 },
actions: {
increment: (c, x: number) => {
Expand Down
3 changes: 0 additions & 3 deletions examples/express/src/registry.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { actor, setup } from "rivetkit";

export const counter = actor({
onAuth: () => {
// Configure auth here
},
state: { count: 0 },
actions: {
increment: (c, x: number) => {
Expand Down
1 change: 0 additions & 1 deletion examples/game/src/backend/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export type Input = { x: number; y: number };
export type Player = { id: string; position: Position; input: Input };

const gameRoom = actor({
onAuth: () => {},
// Persistent state that survives restarts: https://rivet.gg/docs/actors/state
state: {
players: {} as Record<string, Player>,
Expand Down
3 changes: 0 additions & 3 deletions examples/hono-react/src/backend/registry.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { actor, setup } from "rivetkit";

export const counter = actor({
onAuth: () => {
// Configure auth here
},
state: { count: 0 },
actions: {
increment: (c, x: number) => {
Expand Down
4 changes: 1 addition & 3 deletions examples/hono/src/registry.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { actor, setup } from "rivetkit";

export const counter = actor({
onAuth: () => {
// Configure auth here
},
,
state: { count: 0 },
actions: {
increment: (c, x: number) => {
Expand Down
3 changes: 0 additions & 3 deletions examples/next-js/src/rivet/registry.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { actor, setup } from "rivetkit";

export const counter = actor({
onAuth: () => {
// Configure auth here
},
state: { count: 0 },
actions: {
increment: (c, x: number) => {
Expand Down
1 change: 0 additions & 1 deletion examples/rate/src/backend/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export type RateLimitResult = {
};

export const rateLimiter = actor({
onAuth: () => {},
// Persistent state that survives restarts: https://rivet.gg/docs/actors/state
state: {
count: 0,
Expand Down
4 changes: 0 additions & 4 deletions examples/raw-fetch-handler/src/backend/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ export const counter = actor({
state: {
count: 0,
},
onAuth: () => {
// Skip auth, make onFetch public
return {};
},
createVars: () => {
// Setup router
return { router: createCounterRouter() };
Expand Down
4 changes: 0 additions & 4 deletions examples/raw-websocket-handler-proxy/src/backend/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ export const chatRoom = actor({
timestamp: number;
}>,
},
onAuth: () => {
// Skip auth, make WebSocket handler public
return {};
},
createVars: () => {
return {
sockets: new Set<any>(),
Expand Down
3 changes: 0 additions & 3 deletions examples/react/src/backend/registry.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { actor, setup } from "rivetkit";

export const counter = actor({
onAuth: () => {
// Configure auth here
},
state: { count: 0 },
actions: {
increment: (c, x: number) => {
Expand Down
3 changes: 0 additions & 3 deletions examples/starter/src/registry.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { actor, setup } from "rivetkit";

export const counter = actor({
onAuth: () => {
// Configure auth here
},
state: { count: 0 },
actions: {
increment: (c, x: number) => {
Expand Down
1 change: 0 additions & 1 deletion examples/stream/src/backend/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export type StreamState = {
};

const streamProcessor = actor({
onAuth: () => {},
// Persistent state that survives restarts: https://rivet.gg/docs/actors/state
state: {
topValues: [] as number[],
Expand Down
1 change: 0 additions & 1 deletion examples/sync/src/backend/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export type Contact = {
};

const contacts = actor({
onAuth: () => {},
// State is automatically persisted
// Persistent state that survives restarts: https://rivet.gg/docs/actors/state
state: {
Expand Down
1 change: 0 additions & 1 deletion examples/tenant/src/backend/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export type ConnState = {
};

const tenant = actor({
onAuth: () => {},
// Persistent state that survives restarts: https://rivet.gg/docs/actors/state
state: {
orgId: "org-1",
Expand Down
3 changes: 0 additions & 3 deletions examples/trpc/src/registry.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { actor, setup } from "rivetkit";

export const counter = actor({
onAuth: () => {
// Configure auth here
},
state: { count: 0 },
actions: {
increment: (c, x: number) => {
Expand Down
6 changes: 1 addition & 5 deletions packages/cloudflare-workers/src/actor-handler-do.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ import { DurableObject, env } from "cloudflare:workers";
import type { ExecutionContext } from "hono";
import invariant from "invariant";
import type { ActorKey, ActorRouter, Registry, RunConfig } from "rivetkit";
import {
createActorRouter,
createClientWithDriver,
createInlineClientDriver,
} from "rivetkit";
import { createActorRouter, createClientWithDriver } from "rivetkit";
import { serializeEmptyPersistData } from "rivetkit/driver-helpers";
import {
CloudflareDurableObjectGlobalState,
Expand Down
7 changes: 2 additions & 5 deletions packages/cloudflare-workers/src/manager-driver.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Context as HonoContext } from "hono";
import type { Encoding } from "rivetkit";
import type { Encoding, UniversalWebSocket } from "rivetkit";
import {
type ActorOutput,
type CreateInput,
Expand All @@ -9,7 +9,6 @@ import {
HEADER_AUTH_DATA,
HEADER_CONN_PARAMS,
HEADER_ENCODING,
HEADER_EXPOSE_INTERNAL_ERROR,
type ManagerDisplayInformation,
type ManagerDriver,
} from "rivetkit/driver-helpers";
Expand Down Expand Up @@ -69,7 +68,7 @@ export class CloudflareActorsManagerDriver implements ManagerDriver {
actorId: string,
encoding: Encoding,
params: unknown,
): Promise<WebSocket> {
): Promise<UniversalWebSocket> {
const env = getCloudflareAmbientEnv();

logger().debug({
Expand All @@ -85,7 +84,6 @@ export class CloudflareActorsManagerDriver implements ManagerDriver {
const headers: Record<string, string> = {
Upgrade: "websocket",
Connection: "Upgrade",
[HEADER_EXPOSE_INTERNAL_ERROR]: "true",
[HEADER_ENCODING]: encoding,
};
if (params) {
Expand Down Expand Up @@ -190,7 +188,6 @@ export class CloudflareActorsManagerDriver implements ManagerDriver {
}

// Add RivetKit headers
actorRequest.headers.set(HEADER_EXPOSE_INTERNAL_ERROR, "true");
actorRequest.headers.set(HEADER_ENCODING, encoding);
if (params) {
actorRequest.headers.set(HEADER_CONN_PARAMS, JSON.stringify(params));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export interface State {

// Test actor that can capture input during creation
export const inputActor = actor({
onAuth: () => {},
createState: (c, input): State => {
return {
initialInput: input,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { actor } from "rivetkit";

// Short timeout actor
export const shortTimeoutActor = actor({
onAuth: () => {},
state: { value: 0 },
options: {
actionTimeout: 50, // 50ms timeout
Expand All @@ -21,7 +20,6 @@ export const shortTimeoutActor = actor({

// Long timeout actor
export const longTimeoutActor = actor({
onAuth: () => {},
state: { value: 0 },
options: {
actionTimeout: 200, // 200ms timeout
Expand All @@ -37,7 +35,6 @@ export const longTimeoutActor = actor({

// Default timeout actor
export const defaultTimeoutActor = actor({
onAuth: () => {},
state: { value: 0 },
actions: {
normalAction: async (c) => {
Expand All @@ -49,7 +46,6 @@ export const defaultTimeoutActor = actor({

// Sync actor (timeout shouldn't apply)
export const syncTimeoutActor = actor({
onAuth: () => {},
state: { value: 0 },
options: {
actionTimeout: 50, // 50ms timeout
Expand Down
3 changes: 0 additions & 3 deletions packages/rivetkit/fixtures/driver-test-suite/action-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { actor, UserError } from "rivetkit";

// Actor with synchronous actions
export const syncActionActor = actor({
onAuth: () => {},
state: { value: 0 },
actions: {
// Simple synchronous action that returns a value directly
Expand All @@ -26,7 +25,6 @@ export const syncActionActor = actor({

// Actor with asynchronous actions
export const asyncActionActor = actor({
onAuth: () => {},
state: { value: 0, data: null as any },
actions: {
// Async action with a delay
Expand Down Expand Up @@ -59,7 +57,6 @@ export const asyncActionActor = actor({

// Actor with promise actions
export const promiseActor = actor({
onAuth: () => {},
state: { results: [] as string[] },
actions: {
// Action that returns a resolved promise
Expand Down
Loading
Loading