Skip to main content
Quickstart

Next.js Quickstart

Connect a Next.js client component to Rivet Actors running in a separate node process.

Run your Rivet registry as a separate node process alongside Next.js. Client components connect to the control plane.

Quickstart

Install RivetKit

In your Next.js project, install the SDK and client integration:

Define an Actor and start the node

Create the registry and a separate entry point under src/rivet/:

Add a client component

Create src/rivet/Counter.tsx and render it from src/app/page.tsx:

Run the node and Next.js

Start the node in one terminal, then your Next.js app in another:

npx tsx --watch src/rivet/node.ts
npm run dev

Open your Next.js app and click Increment. Open http://localhost:6420 to inspect the Actor in the local developer tools.

Deploy

Deploy the node as a long-running process. Set its private RIVET_ENDPOINT and your Next.js app’s NEXT_PUBLIC_RIVET_ENDPOINT to the corresponding production endpoints. Keep the private token on the node.

In development, Rivet runs a local control plane for you and keeps Actor data on your machine.

To scale Rivet in production, pick how much of it you want to run yourself:

If you are running your own nodes, follow the guide for your hosting provider:

See the React Client API Reference for hooks and event subscriptions.