Skip to content
Open
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
17 changes: 4 additions & 13 deletions site/src/content/docs/actors/quickstart/next-js.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ Create a RivetKit client to connect to your actor:
import { createClient, createRivetKit } from "@rivetkit/next-js/client";
import type { registry } from "@/rivet/registry";

const client = createClient<typeof registry>(`${window.location.href}api`, {
const client = createClient<typeof registry>({
endpoint: `${window.location.origin}/api/rivet`,
transport: "sse",
});

Expand All @@ -70,22 +71,12 @@ export const { useActor } = createRivetKit(client);

<Step title="Setup Registry API routes">

```ts {{"title":"src/app/api/registry/[...all]/route.ts"}}
```ts {{"title":"src/app/api/rivet/[...all]/route.ts"}}
import { toNextHandler } from "@rivetkit/next-js";
import { registry } from "@/rivet/registry";

const server = registry.start({
// Use the same base path as the client
// This is important for Next.js to route the API calls correctly
basePath: "/api/registry",
studio: {
// Tell RivetKit Studio where to find RivetKit Registry
defaultEndpoint: "http://localhost:3000/api/registry",
},
});

// Export the Next.js handler for the API routes
export const { GET, POST, HEAD, PATCH, OPTIONS } = toNextHandler(server);
export const { GET, POST, HEAD, PATCH, OPTIONS } = toNextHandler(registry);
```

</Step>
Expand Down
3 changes: 2 additions & 1 deletion site/src/content/docs/clients/next-js.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ Create a RivetKit client to connect to your actor:
import { createClient, createRivetKit } from "@rivetkit/next-js/client";
import type { registry } from "@/rivet/registry";

const client = createClient<typeof registry>(`${window.location.href}api`, {
const client = createClient<typeof registry>({
endpoint: `${window.location.origin}/api/rivet`,
transport: "sse",
});

Expand Down
18 changes: 3 additions & 15 deletions site/src/content/docs/integrations/next-js.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,12 @@ export const registry = setup({

<Step title="Setup Registry API routes">

```ts {{"title":"src/app/api/registry/[...all]/route.ts"}}
```ts {{"title":"src/app/api/rivet/[...all]/route.ts"}}
import { toNextHandler } from "@rivetkit/next-js";
import { registry } from "@/rivet/registry";

const server = registry.start({
// Use the same base path as the client
// This is important for Next.js to route the API calls correctly
basePath: "/api/registry",
studio: {
// Tell RivetKit Studio where to find RivetKit Registry
defaultEndpoint: "http://localhost:3000/api/registry",
},
});

// Export the Next.js handler for the API routes
export const { GET, POST, HEAD, PATCH, OPTIONS } = toNextHandler(server);
export const { GET, POST, HEAD, PATCH, OPTIONS } = toNextHandler(registry);
```

</Step>
Expand All @@ -94,9 +84,7 @@ const registry = setup({
use: { counter },
});

const server = registry.start();

export const { GET, POST, HEAD, PATCH, OPTIONS } = toNextHandler(server);
export const { GET, POST, HEAD, PATCH, OPTIONS } = toNextHandler(registry);
```

#### Parameters
Expand Down
Loading