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
3 changes: 2 additions & 1 deletion examples/ai-agent/src/backend/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { registry } from "./registry";

registry.start({
cors: {
origin: "http://localhost:5173",
origin: "http://localhost:3000",
credentials: true,
},
});
7 changes: 3 additions & 4 deletions examples/ai-agent/src/frontend/App.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { createClient, createRivetKit } from "@rivetkit/react";
import { createRivetKit } from "@rivetkit/react";
import { useEffect, useState } from "react";
import type { Message, registry } from "../backend/registry";

const client = createClient<typeof registry>("http://localhost:8080");
const { useActor } = createRivetKit(client);
const { useActor } = createRivetKit<typeof registry>("http://localhost:8080");

export function App() {
const aiAgent = useActor({
Expand Down Expand Up @@ -77,4 +76,4 @@ export function App() {
</div>
</div>
);
}
}
7 changes: 6 additions & 1 deletion examples/better-auth-external-db/src/backend/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import { auth } from "./auth";
import { registry } from "./registry";

// Start RivetKit
registry.start();
registry.start({
cors: {
origin: "http://localhost:5173",
credentials: true,
},
});

// Setup router
const app = new Hono();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { createClient, createRivetKit } from "@rivetkit/react";
import { createRivetKit } from "@rivetkit/react";
import { useEffect, useState } from "react";
import type { registry } from "../../backend/registry";
import { authClient } from "../auth-client";

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

const { useActor } = createRivetKit(client);
const { useActor } = createRivetKit<typeof registry>("http://localhost:8080");

interface ChatRoomProps {
user: { id: string; email: string };
Expand Down
5 changes: 2 additions & 3 deletions examples/chat-room/src/frontend/App.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { createClient, createRivetKit } from "@rivetkit/react";
import { createRivetKit } from "@rivetkit/react";
import { useEffect, useState } from "react";
import type { Message, registry } from "../backend/registry";

const client = createClient<typeof registry>("http://localhost:6420");
const { useActor } = createRivetKit(client);
const { useActor } = createRivetKit<typeof registry>("http://localhost:6420");

export function App() {
const [roomId, setRoomId] = useState("general");
Expand Down
3 changes: 2 additions & 1 deletion examples/crdt/src/backend/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { registry } from "./registry";

registry.start({
cors: {
origin: "http://localhost:5173",
origin: "http://localhost:3000",
credentials: true,
},
});
7 changes: 3 additions & 4 deletions examples/crdt/src/frontend/App.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { createClient, createRivetKit } from "@rivetkit/react";
import { createRivetKit } from "@rivetkit/react";
import { useEffect, useRef, useState } from "react";
import * as Y from "yjs";
import { applyUpdate, encodeStateAsUpdate } from "yjs";
import type { registry } from "../backend/registry";

const client = createClient<typeof registry>("http://localhost:8080");
const { useActor } = createRivetKit(client);
const { useActor } = createRivetKit<typeof registry>("http://localhost:8080");

function YjsEditor({ documentId }: { documentId: string }) {
const yjsDocument = useActor({
Expand Down Expand Up @@ -192,4 +191,4 @@ function bufferToBase64(buffer: Uint8Array): string {
binary += String.fromCharCode(buffer[i]);
}
return btoa(binary);
}
}
3 changes: 2 additions & 1 deletion examples/database/src/backend/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { registry } from "./registry";

registry.start({
cors: {
origin: "http://localhost:5173",
origin: "http://localhost:3000",
credentials: true,
},
});
7 changes: 3 additions & 4 deletions examples/database/src/frontend/App.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { createClient, createRivetKit } from "@rivetkit/react";
import { createRivetKit } from "@rivetkit/react";
import { useEffect, useState } from "react";
import type { Note, registry } from "../backend/registry";

const client = createClient<typeof registry>("http://localhost:8080");
const { useActor } = createRivetKit(client);
const { useActor } = createRivetKit<typeof registry>("http://localhost:8080");

function NotesApp({ userId }: { userId: string }) {
const [notes, setNotes] = useState<Note[]>([]);
Expand Down Expand Up @@ -199,4 +198,4 @@ export function App() {
<NotesApp key={selectedUser} userId={selectedUser} />
</div>
);
}
}
5 changes: 2 additions & 3 deletions examples/freestyle/src/frontend/App.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { createClient, createRivetKit } from "@rivetkit/react";
import { createRivetKit } from "@rivetkit/react";
import { useEffect, useState } from "react";
import type { Message, registry } from "../backend/registry";

const client = createClient<typeof registry>({
const { useActor } = createRivetKit<typeof registry>({
endpoint: import.meta.env.VITE_RIVET_ENDPOINT ?? "http://localhost:8080/api",
namespace: import.meta.env.VITE_RIVET_NAMESPACE,
runnerName: import.meta.env.VITE_RIVET_RUNNER_NAME ?? "freestyle-runner",
});
const { useActor } = createRivetKit(client);

export function App() {
const [roomId, setRoomId] = useState("general");
Expand Down
3 changes: 2 additions & 1 deletion examples/game/src/backend/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { registry } from "./registry";

registry.start({
cors: {
origin: "http://localhost:5173",
origin: "http://localhost:3000",
credentials: true,
},
});
7 changes: 3 additions & 4 deletions examples/game/src/frontend/App.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { createClient, createRivetKit } from "@rivetkit/react";
import { createRivetKit } from "@rivetkit/react";
import { useEffect, useRef, useState } from "react";
import type { Player, registry } from "../backend/registry";

const client = createClient<typeof registry>("http://localhost:8080");
const { useActor } = createRivetKit(client);
const { useActor } = createRivetKit<typeof registry>("http://localhost:8080");

export function App() {
const [players, setPlayers] = useState<Player[]>([]);
Expand Down Expand Up @@ -200,4 +199,4 @@ export function App() {
</div>
</div>
);
}
}
1 change: 1 addition & 0 deletions examples/hono-bun/src/backend/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const { client, fetch } = registry.start({
getUpgradeWebSocket: () => upgradeWebSocket,
cors: {
origin: "http://localhost:5173",
credentials: true,
},
});

Expand Down
5 changes: 2 additions & 3 deletions examples/hono-bun/src/frontend/App.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { createClient, createRivetKit } from "@rivetkit/react";
import { createRivetKit } from "@rivetkit/react";
import { useState } from "react";
import type { registry } from "../backend/registry";

const client = createClient<typeof registry>("http://localhost:8080/rivet");
const { useActor } = createRivetKit<typeof registry>(client);
const { useActor } = createRivetKit<typeof registry>("http://localhost:8080/rivet");

function App() {
const [count, setCount] = useState(0);
Expand Down
1 change: 1 addition & 0 deletions examples/hono-react/src/backend/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { registry } from "./registry";
const { client } = registry.start({
cors: {
origin: "http://localhost:5173",
credentials: true,
},
});

Expand Down
5 changes: 2 additions & 3 deletions examples/hono-react/src/frontend/App.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { createClient, createRivetKit } from "@rivetkit/react";
import { createRivetKit } from "@rivetkit/react";
import { useState } from "react";
import type { registry } from "../backend/registry";

const client = createClient<typeof registry>("http://localhost:8080");
const { useActor } = createRivetKit<typeof registry>(client);
const { useActor } = createRivetKit<typeof registry>("http://localhost:8080");

function App() {
const [count, setCount] = useState(0);
Expand Down
8 changes: 7 additions & 1 deletion examples/next-js/src/components/Counter.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
"use client";

import { createRivetKit } from "@rivetkit/next-js/client";
import type { registry } from "@/rivet/registry";
import { useState } from "react";
import { useActor } from "@/lib/rivet-client";
import styles from "./Counter.module.css";

export const { useActor } = createRivetKit<typeof registry>(
process.env.NEXT_RIVET_ENDPOINT ?? "http://localhost:3000/api/rivet",
);

export function Counter() {
const [count, setCount] = useState(0);
const [counterName, setCounterName] = useState("test-counter");
Expand Down
8 changes: 0 additions & 8 deletions examples/next-js/src/lib/rivet-client.ts

This file was deleted.

3 changes: 2 additions & 1 deletion examples/rate/src/backend/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { registry } from "./registry";

registry.start({
cors: {
origin: "http://localhost:5173",
origin: "http://localhost:3000",
credentials: true,
},
});
7 changes: 3 additions & 4 deletions examples/rate/src/frontend/App.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { createClient, createRivetKit } from "@rivetkit/react";
import { createRivetKit } from "@rivetkit/react";
import { useEffect, useState } from "react";
import type { RateLimitResult, registry } from "../backend/registry";

const client = createClient<typeof registry>("http://localhost:8080");
const { useActor } = createRivetKit(client);
const { useActor } = createRivetKit<typeof registry>("http://localhost:8080");

function RateLimiterDemo({ userId }: { userId: string }) {
const [result, setResult] = useState<RateLimitResult | null>(null);
Expand Down Expand Up @@ -147,4 +146,4 @@ export function App() {
</div>
</div>
);
}
}
8 changes: 7 additions & 1 deletion examples/raw-fetch-handler/src/backend/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,20 @@ import { cors } from "hono/cors";
import { registry } from "./registry";

// Start RivetKit
const { client } = registry.start();
const { client } = registry.start({
cors: {
origin: "http://localhost:5173",
credentials: true,
},
});

// Setup router
const app = new Hono();

app.use(
cors({
origin: "http://localhost:5173",
credentials: true,
}),
);

Expand Down
7 changes: 6 additions & 1 deletion examples/raw-websocket-handler-proxy/src/backend/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ import { createNodeWebSocket } from "@hono/node-ws";
import { Hono } from "hono";
import { registry } from "./registry.js";

const { client } = registry.start();
const { client } = registry.start({
cors: {
origin: "http://localhost:5173",
credentials: true,
},
});

const app = new Hono();
const { injectWebSocket, upgradeWebSocket } = createNodeWebSocket({ app });
Expand Down
5 changes: 2 additions & 3 deletions examples/raw-websocket-handler/src/frontend/App.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React, { useState, useEffect, useRef } from "react";
import { createClient, createRivetKit } from "@rivetkit/react";
import { createRivetKit } from "@rivetkit/react";
import type { registry } from "../backend/registry";

const client = createClient<typeof registry>();
const { useActor } = createRivetKit(client);
const { useActor } = createRivetKit<typeof registry>("http://localhost:8080");

export default function App() {
const [messages, setMessages] = useState<Array<{ id: string; text: string; timestamp: number }>>([]);
Expand Down
1 change: 1 addition & 0 deletions examples/react/src/backend/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ import { registry } from "./registry";
registry.start({
cors: {
origin: "http://localhost:5173",
credentials: true,
},
});
5 changes: 2 additions & 3 deletions examples/react/src/frontend/App.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { createClient, createRivetKit } from "@rivetkit/react";
import { createRivetKit } from "@rivetkit/react";
import { useState } from "react";
import type { registry } from "../backend/registry";

const client = createClient<typeof registry>();
const { useActor } = createRivetKit(client);
const { useActor } = createRivetKit<typeof registry>("http://localhost:8080");

function App() {
const [count, setCount] = useState(0);
Expand Down
3 changes: 2 additions & 1 deletion examples/stream/src/backend/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { registry } from "./registry";

registry.start({
cors: {
origin: "http://localhost:5173",
origin: "http://localhost:3000",
credentials: true,
},
});
7 changes: 3 additions & 4 deletions examples/stream/src/frontend/App.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { createClient, createRivetKit } from "@rivetkit/react";
import { createRivetKit } from "@rivetkit/react";
import { useEffect, useState } from "react";
import type { registry } from "../backend/registry";

const client = createClient<typeof registry>("http://localhost:8080");
const { useActor } = createRivetKit(client);
const { useActor } = createRivetKit<typeof registry>("http://localhost:8080");

export function App() {
const [topValues, setTopValues] = useState<number[]>([]);
Expand Down Expand Up @@ -179,4 +178,4 @@ export function App() {
</div>
</div>
);
}
}
3 changes: 2 additions & 1 deletion examples/sync/src/backend/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { registry } from "./registry";

registry.start({
cors: {
origin: "http://localhost:5173",
origin: "http://localhost:3000",
credentials: true,
},
});
7 changes: 3 additions & 4 deletions examples/sync/src/frontend/App.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { createClient, createRivetKit } from "@rivetkit/react";
import { createRivetKit } from "@rivetkit/react";
import { useEffect, useRef, useState } from "react";
import type { Contact, registry } from "../backend/registry";

const client = createClient<typeof registry>("http://localhost:8080");
const { useActor } = createRivetKit(client);
const { useActor } = createRivetKit<typeof registry>("http://localhost:8080");

export function App() {
const [contacts, setContacts] = useState<Contact[]>([]);
Expand Down Expand Up @@ -342,4 +341,4 @@ export function App() {
</div>
</div>
);
}
}
3 changes: 2 additions & 1 deletion examples/tenant/src/backend/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { registry } from "./registry";

registry.start({
cors: {
origin: "http://localhost:5173",
origin: "http://localhost:3000",
credentials: true,
},
});
Loading
Loading