Back to Rivet

Node.js & Bun Quickstart

website/src/content/docs/actors/quickstart/backend.mdx

2.3.32.0 KB
Original Source

import { Hosting } from "@/components/docs/Hosting"; import { ConfigurationOptions } from "@/components/docs/ConfigurationOptions";

<Note> Prefer to start from a complete project? See the runnable [`hello-world`](https://github.com/rivet-dev/rivet/tree/main/examples/hello-world) example. </Note>

Steps

<Steps> <Step title="Add Rivet Skill to Coding Agent (Optional)">

If you're using an AI coding assistant (like Claude Code, Cursor, Windsurf, etc.), add Rivet skills for enhanced development assistance:

sh
npx skills add rivet-dev/skills
</Step> <Step title="Install Rivet">
sh
npm install rivetkit
</Step> <Step title="Create Actors and Start Server">

Create a file with your actors, set up the registry, and start the server:

<CodeSnippet file="examples/docs/actors-quickstart-backend/index.ts" title="index.ts" /> </Step> <Step title="Run Server"> <CodeGroup>
sh
npx tsx --watch index.ts
sh
bun --watch index.ts
sh
deno run --allow-net --allow-read --allow-env --watch index.ts
</CodeGroup>

Your server is now running on http://localhost:6420. Clients connect directly to the Rivet Engine on this port.

Visit http://localhost:6420 in your browser (or point your AI agent at it) to open the Rivet developer tools and inspect your actors live.

</Step> <Step title="Connect To The Rivet Actor">

This code can run either in your frontend or within your backend:

<Tabs> <Tab title="TypeScript"> <CodeGroup> <CodeSnippet file="examples/docs/actors-quickstart-backend/client.ts" title="client.ts" /> </CodeGroup>

See the JavaScript client documentation for more information.

</Tab> <Tab title="React"> <CodeGroup> <CodeSnippet file="examples/docs/actors-quickstart-backend/Counter.tsx" title="Counter.tsx" /> </CodeGroup>

See the React documentation for more information.

</Tab> </Tabs> </Step> <Step title="Deploy"> <Hosting /> </Step> </Steps>

Configuration Options

<ConfigurationOptions />