### Install and Run Example Source: https://github.com/rivet-dev/rivet/blob/main/examples/sqlite-raw/README.md Clone the repository, navigate to the example directory, and install dependencies using npm or pnpm. Run the development server to start the application. ```sh git clone https://github.com/rivet-dev/rivet.git cd rivet/examples/sqlite-raw npm install npm run dev ``` ```bash pnpm install pnpm dev ``` -------------------------------- ### Install and Run React Example Source: https://github.com/rivet-dev/rivet/blob/main/examples/react/README.md Clone the Rivet repository, navigate to the React example directory, install dependencies, and start the development server. ```sh git clone https://github.com/rivet-dev/rivet.git cd rivet/examples/react npm install npm run dev ``` -------------------------------- ### Install and Run Example Source: https://github.com/rivet-dev/rivet/blob/main/examples/cross-actor-actions/README.md Clone the repository, navigate to the example directory, install dependencies, and run the development server. ```sh git clone https://github.com/rivet-dev/rivet.git cd rivet/examples/cross-actor-actions npm install npm run dev ``` -------------------------------- ### Install and Run Example Project Source: https://github.com/rivet-dev/rivet/blob/main/examples/raw-fetch-handler/README.md Clone the repository, navigate to the example directory, install dependencies, and run the development server. ```sh git clone https://github.com/rivet-dev/rivet.git cd rivet/examples/raw-fetch-handler npm install npm run dev ``` -------------------------------- ### Install and Run Next.js Example Source: https://github.com/rivet-dev/rivet/blob/main/examples/next-js/README.md Clone the Rivet repository, navigate to the Next.js example directory, install dependencies, and start the development server. ```sh git clone https://github.com/rivet-dev/rivet.git cd rivet/examples/next-js npm install npm run dev ``` -------------------------------- ### Install and Run Example Source: https://github.com/rivet-dev/rivet/blob/main/examples/cursors/README.md Clone the repository, navigate to the cursors example directory, install dependencies, and run the development server. ```sh git clone https://github.com/rivet-dev/rivet.git cd rivet/examples/cursors npm install npm run dev ``` -------------------------------- ### Install Dependencies and Run Example Source: https://github.com/rivet-dev/rivet/blob/main/examples/dynamic-actors/README.md Navigate to the example directory, install dependencies using pnpm, and then run the development server. ```sh cd examples/dynamic-actors pnpm install pnpm dev ``` -------------------------------- ### Install and Run Hono + React Example Source: https://github.com/rivet-dev/rivet/blob/main/examples/hono-react-vercel/README.md Clone the repository, install dependencies, and start the development server to run the Hono and React example. ```sh git clone https://github.com/rivet-dev/rivet.git cd rivet/examples/hono-react npm install npm run dev ``` -------------------------------- ### Install and Run RivetKit Kitchen Sink Example Source: https://github.com/rivet-dev/rivet/blob/main/examples/kitchen-sink/README.md Clone the Rivet repository, navigate to the kitchen-sink example directory, install dependencies, and start the development server. ```sh git clone https://github.com/rivet-dev/rivet.git cd rivet/examples/kitchen-sink npm install npm run dev ``` -------------------------------- ### Install and Run Elysia Example Source: https://github.com/rivet-dev/rivet/blob/main/examples/elysia/README.md Clone the Rivet repository, navigate to the Elysia example directory, install dependencies, and start the development server. ```sh git clone https://github.com/rivet-dev/rivet.git cd rivet/examples/elysia npm install npm run dev ``` -------------------------------- ### Install Dependencies and Run Dev Server Source: https://github.com/rivet-dev/rivet/blob/main/examples/sandbox-coding-agent-vercel/README.md Clone the repository, navigate to the example directory, install dependencies using pnpm, and start the development server. ```sh git clone https://github.com/rivet-dev/rivet.git cd rivet/examples/sandbox-coding-agent-vercel pnpm install pnpm dev ``` -------------------------------- ### Install and Run Multi-Region Example Source: https://github.com/rivet-dev/rivet/blob/main/examples/multi-region-vercel/README.md Clone the repository, install dependencies, and run the development server for the multi-region example. ```sh git clone https://github.com/rivet-dev/rivet.git cd rivet/examples/multi-region npm install npm run dev ``` -------------------------------- ### Install and Run Hello World Example Source: https://github.com/rivet-dev/rivet/blob/main/examples/hello-world/README.md Clone the Rivet repository, navigate to the hello-world example directory, install dependencies, and run the development server. ```sh git clone https://github.com/rivet-dev/rivet.git cd rivet/examples/hello-world npm install npm run dev ``` -------------------------------- ### Install and Run Chat Room Example Source: https://github.com/rivet-dev/rivet/blob/main/examples/chat-room/README.md Clone the Rivet repository, navigate to the chat room example directory, install dependencies, and start the development server. ```sh git clone https://github.com/rivet-dev/rivet.git cd rivet/examples/chat-room npm install npm run dev ``` -------------------------------- ### Install and Run Collaborative Document Example Source: https://github.com/rivet-dev/rivet/blob/main/examples/collaborative-document/README.md Clone the repository, navigate to the example directory, install dependencies, and run the development server. ```sh git clone https://github.com/rivet-dev/rivet.git cd rivet/examples/collaborative-document npm install npm run dev ``` -------------------------------- ### Install and Run Multiplayer Game Example Source: https://github.com/rivet-dev/rivet/blob/main/examples/multiplayer-game-vercel/README.md Clone the repository, navigate to the example directory, install dependencies, and run the development server. ```sh git clone https://github.com/rivet-dev/rivet.git cd rivet/examples/multiplayer-game npm install npm run dev ``` -------------------------------- ### Install and Run Server Source: https://github.com/rivet-dev/rivet/blob/main/rivetkit-swift/examples/hello-world-cli/README.md Navigate to the server directory, install dependencies, and start the server. The server listens on http://127.0.0.1:8787. ```bash cd rivetkit-swift/examples/hello-world-cli/server pnpm install pnpm dev ``` -------------------------------- ### Install and Run Server Source: https://github.com/rivet-dev/rivet/blob/main/rivetkit-swift/examples/hello-world-swiftui/README.md Navigate to the server directory, install dependencies, and start the server. The server listens on http://127.0.0.1:8787. ```bash cd rivetkit-swift/examples/hello-world-swiftui/server pnpm install pnpm dev ``` -------------------------------- ### Clone and Run Example Source: https://github.com/rivet-dev/rivet/blob/main/examples/per-tenant-database-vercel/README.md Clone the repository, navigate to the example directory, install dependencies, and run the development server. ```sh git clone https://github.com/rivet-dev/rivet.git cd rivet/examples/per-tenant-database npm install npm run dev ``` -------------------------------- ### Install and Run Custom Serverless Example Source: https://github.com/rivet-dev/rivet/blob/main/examples/custom-serverless/README.md Clone the Rivet repository, navigate to the custom serverless example directory, install dependencies, and run the development server. ```sh git clone https://github.com/rivet-dev/rivet.git cd rivet/examples/custom-serverless npm install npm run dev ``` -------------------------------- ### Install and Run Hono Example Source: https://github.com/rivet-dev/rivet/blob/main/examples/hono/README.md Clone the Rivet repository, navigate to the Hono example directory, install dependencies, and run the development server. ```sh git clone https://github.com/rivet-dev/rivet.git cd rivet/examples/hono npm install npm run dev ``` -------------------------------- ### Install and Run WebSocket Handler Example Source: https://github.com/rivet-dev/rivet/blob/main/examples/raw-websocket-handler/README.md Clone the Rivet repository, navigate to the raw-websocket-handler example directory, install dependencies, and run the development server. ```sh git clone https://github.com/rivet-dev/rivet.git cd rivet/examples/raw-websocket-handler npm install npm run dev ``` -------------------------------- ### Install and Run tRPC Example Source: https://github.com/rivet-dev/rivet/blob/main/examples/trpc/README.md Clone the Rivet repository, navigate to the tRPC example directory, install dependencies, and run the development server. ```sh git clone https://github.com/rivet-dev/rivet.git cd rivet/examples/trpc npm install npm run dev ``` -------------------------------- ### Clone and Install Rivet Example Source: https://github.com/rivet-dev/rivet/blob/main/examples/state-render/README.md Use these commands to clone the Rivet repository, navigate to the state example directory, install dependencies, and run the development server. ```sh git clone https://github.com/rivet-dev/rivet.git cd rivet/examples/state npm install npm run dev ``` -------------------------------- ### Clone and Run Example Source: https://github.com/rivet-dev/rivet/blob/main/examples/cursors-raw-websocket/README.md Clone the Rivet repository, navigate to the example directory, install dependencies, and run the development server. ```sh git clone https://github.com/rivet-dev/rivet.git cd rivet/examples/cursors-raw-websocket npm install npm run dev ``` -------------------------------- ### Clone and Run Example Project Source: https://github.com/rivet-dev/rivet/blob/main/examples/experimental-durable-streams-ai-agent/README.md Clone the Rivet repository, navigate to the example directory, install dependencies, and run the development server. ```sh git clone https://github.com/rivet-dev/rivet.git cd rivet/examples/experimental-durable-streams-ai-agent npm install npm run dev ``` -------------------------------- ### Run Hello World Server Source: https://github.com/rivet-dev/rivet/blob/main/examples/agent-os/README.md Starts the server for the 'hello-world' example, which involves writing and reading a file within the VM. Run this in one terminal. ```bash pnpm hello-world:server ``` -------------------------------- ### Run Tools Server Source: https://github.com/rivet-dev/rivet/blob/main/examples/agent-os/README.md Starts the server for the 'tools' example, which defines host toolkits callable from inside the VM. Run this in one terminal. ```bash pnpm tools:server ``` -------------------------------- ### Clone and Run Scheduling Example Source: https://github.com/rivet-dev/rivet/blob/main/examples/scheduling/README.md Clone the Rivet repository, navigate to the scheduling examples, install dependencies, and run the development server. ```sh git clone https://github.com/rivet-dev/rivet.git cd rivet/examples/scheduling npm install npm run dev ``` -------------------------------- ### Run Sandbox Server Source: https://github.com/rivet-dev/rivet/blob/main/examples/agent-os/README.md Starts the server for the 'sandbox' example, which mounts a sandbox into the VM. Requires Docker for local sandbox demonstration. Run this in one terminal. ```bash pnpm sandbox:server ``` -------------------------------- ### Clone and Install Project Source: https://github.com/rivet-dev/rivet/blob/main/examples/geo-distributed-database-vercel/README.md Clone the Rivet repository, navigate to the geo-distributed database example directory, install dependencies, and run the development server. ```sh git clone https://github.com/rivet-dev/rivet.git cd rivet/examples/geo-distributed-database npm install npm run dev ``` -------------------------------- ### Clone and Run Example Project Source: https://github.com/rivet-dev/rivet/blob/main/examples/multiplayer-game-patterns-vercel/README.md Clone the Rivet repository, navigate to the multiplayer game patterns example directory, install dependencies, and run the development server. ```sh git clone https://github.com/rivet-dev/rivet.git cd rivet/examples/multiplayer-game-patterns pnpm install pnpm dev ``` -------------------------------- ### Run Git Server Source: https://github.com/rivet-dev/rivet/blob/main/examples/agent-os/README.md Starts the server for the 'git' example, which demonstrates cloning a repository and checking out a branch within the VM. Execute this in one terminal. ```bash pnpm git:server ``` -------------------------------- ### Clone and Run Native WebSocket Example Source: https://github.com/rivet-dev/rivet/blob/main/examples/native-websockets-vercel/README.md Clone the Rivet repository, navigate to the native-websockets example directory, install dependencies, and run the development server. ```sh git clone https://github.com/rivet-dev/rivet.git cd rivet/examples/native-websockets npm install npm run dev ``` -------------------------------- ### Run Tools Client Source: https://github.com/rivet-dev/rivet/blob/main/examples/agent-os/README.md Executes the client for the 'tools' example. This connects to the server to utilize the defined host toolkits. Use this in a separate terminal after starting the server. ```bash pnpm tools ``` -------------------------------- ### Clone and Run Drizzle Example Source: https://github.com/rivet-dev/rivet/blob/main/examples/sqlite-drizzle/README.md Clone the Rivet repository, navigate to the SQLite Drizzle example directory, install dependencies, and run the development server. ```sh git clone https://github.com/rivet-dev/rivet.git cd rivet/examples/sqlite-drizzle npm install npm run dev ``` -------------------------------- ### Clone and Run Actor Actions Example Source: https://github.com/rivet-dev/rivet/blob/main/examples/actor-actions/README.md Clone the Rivet repository, navigate to the actor-actions example directory, install dependencies, and run the development server. ```sh git clone https://github.com/rivet-dev/rivet.git cd rivet/examples/actor-actions npm install npm run dev ``` -------------------------------- ### Project Setup and Version Check Source: https://github.com/rivet-dev/rivet/blob/main/website/src/metadata/skill-base-rivetkit.md Instructions for setting up a Rivet project, including version checking and installation. ```APIDOC ## Version Check Before starting, ensure your project uses the latest RivetKit version. ### Checking Version Look at the `rivetkit` version in your `package.json` (both `dependencies` and `devDependencies`). ### Upgrading RivetKit If your installed version is older than the latest, upgrade using: ```bash npm install rivetkit@{{RIVETKIT_VERSION}} ``` Also, upgrade any related `@rivetkit/*` client packages (e.g., `@rivetkit/react`, `@rivetkit/next-js`). ## First Steps 1. **Install RivetKit** (latest: {{RIVETKIT_VERSION}}) ```bash npm install rivetkit@{{RIVETKIT_VERSION}} ``` 2. **Define Registry** Define a registry with `setup({ use: { /* actors */ } })`. 3. **Start Server** - For custom HTTP server integration: `registry.handler()` with a router (e.g., Hono). - For serverless deployments: `registry.serve()`. - For runner-only mode: `registry.startRunner()`. - To start the server: `registry.start()`. 4. **Verify Metadata** Ensure `/api/rivet/metadata` returns 200 before deploying. 5. **Configure Cloud/Engine** Configure versioning for production builds. Not needed for local development. See [Versions & Upgrades](https://rivet.dev/docs/actors/versions). 6. **Integrate Clients** Follow client guides for JavaScript, React, or Swift. 7. **Deploy** Prompt the user if they want to deploy, then proceed to Deploying Rivet Backends. ``` -------------------------------- ### Set up Pi Agent Server Source: https://github.com/rivet-dev/rivet/blob/main/website/src/content/docs/agent-os/agents/pi.mdx Configure and start the Pi agent VM with common software and Pi-specific modules. This is the server-side setup. ```typescript import { agentOs } from "rivetkit/agent-os"; import { setup } from "rivetkit"; import common from "@rivet-dev/agent-os-common"; import pi from "@rivet-dev/agent-os-pi"; const vm = agentOs({ options: { software: [common, pi] }, }); export const registry = setup({ use: { vm } }); registry.start(); ``` -------------------------------- ### Clone and Run AI Agent Example Source: https://github.com/rivet-dev/rivet/blob/main/examples/ai-agent-vercel/README.md Clone the Rivet repository, navigate to the AI agent example directory, install dependencies, and run the development server. ```sh git clone https://github.com/rivet-dev/rivet.git cd rivet/examples/ai-agent npm install npm run dev ``` -------------------------------- ### Run Sandbox Client Source: https://github.com/rivet-dev/rivet/blob/main/examples/agent-os/README.md Executes the client for the 'sandbox' example. This connects to the server to interact with the mounted sandbox environment. Use this in a separate terminal after starting the server. ```bash pnpm sandbox ``` -------------------------------- ### Run Cron Server Source: https://github.com/rivet-dev/rivet/blob/main/examples/agent-os/README.md Starts the server for the 'cron' example, which allows scheduling and managing recurring jobs within the VM. Execute this in one terminal. ```bash pnpm cron:server ``` -------------------------------- ### Run Git Client Source: https://github.com/rivet-dev/rivet/blob/main/examples/agent-os/README.md Runs the client for the 'git' example. This connects to the server to perform Git operations. Use this in a separate terminal after starting the server. ```bash pnpm git ``` -------------------------------- ### Clone and Run Rivet Sandbox Source: https://github.com/rivet-dev/rivet/blob/main/examples/sandbox-vercel/README.md Instructions to clone the Rivet repository, navigate to the sandbox example directory, install dependencies, and start the development server. ```sh git clone https://github.com/rivet-dev/rivet.git cd rivet/examples/sandbox npm install npm run dev ``` -------------------------------- ### Get Engine Path and Spawn Process Source: https://github.com/rivet-dev/rivet/blob/main/rivetkit-typescript/packages/engine-cli/README.md Use `getEnginePath` to retrieve the absolute path to the rivet-engine binary for the current host. This path can then be used with Node.js's `child_process.spawn` to execute the engine, for example, to start it. ```javascript const { getEnginePath } = require("@rivetkit/engine-cli"); const { spawn } = require("node:child_process"); const child = spawn(getEnginePath(), ["start"]); ``` -------------------------------- ### Install Dependencies for Vercel Examples Source: https://github.com/rivet-dev/rivet/blob/main/CLAUDE.md If you encounter 'node_modules missing' warnings after regenerating Vercel examples, run 'pnpm install' to reinstall dependencies. ```bash pnpm install ``` -------------------------------- ### Run Hello World Client Source: https://github.com/rivet-dev/rivet/blob/main/examples/agent-os/README.md Executes the client for the 'hello-world' example. This connects to the server to perform file operations. Run this in a separate terminal after starting the server. ```bash pnpm hello-world ``` -------------------------------- ### Run All RivetKit Example Tests Source: https://github.com/rivet-dev/rivet/blob/main/scripts/test-examples/README.md Execute tests for all examples in the RivetKit project. This command starts the dev server for each example and verifies its endpoints. ```bash pnpm start ``` -------------------------------- ### Define and Run a Durable Workflow Source: https://context7.com/rivet-dev/rivet/llms.txt This snippet defines an order processing workflow using RivetKit's `actor` and `workflow` utilities. It includes setup, a processing loop with queue handling, durable steps with retries and rollbacks, and client-side usage for interacting with the workflow. Ensure RivetKit is installed and the registry is started. ```typescript import { actor, queue, setup } from "rivetkit"; import { workflow, Loop } from "rivetkit/workflow"; import { createClient } from "rivetkit/client"; const orderProcessor = actor({ state: { orderId: null as string | null, status: "pending" as "pending" | "processing" | "completed" | "failed", steps: [] as string[], }, queues: { orders: queue<{ orderId: string; amount: number }>(), control: queue<{ action: "cancel" }>(), }, run: workflow(async (ctx) => { // Setup step - runs once await ctx.step("initialize", async () => { ctx.state.status = "processing"; ctx.state.steps.push("initialized"); }); // Main processing loop const result = await ctx.loop("order-loop", async (loopCtx) => { // Wait for next message from any queue const message = await loopCtx.queue.next("wait-message", { names: ["orders", "control"], }); if (message.name === "control") { // Exit loop with result return Loop.break("cancelled"); } const order = message.body as { orderId: string; amount: number }; // Durable step with retries await loopCtx.step({ name: "validate-order", timeout: 5000, maxRetries: 3, run: async () => { const res = await fetch(`https://api.example.com/orders/${order.orderId}/validate`); if (!res.ok) throw new Error("Validation failed"); loopCtx.state.steps.push(`validated:${order.orderId}`); }, }); // Charge with rollback support await loopCtx.rollbackCheckpoint("payment-checkpoint"); await loopCtx.step({ name: "charge-payment", run: async () => { await fetch("https://api.stripe.com/v1/charges", { method: "POST", body: JSON.stringify({ amount: order.amount }), }); loopCtx.state.steps.push(`charged:${order.orderId}`); }, rollback: async () => { // Compensating action on failure await fetch("https://api.stripe.com/v1/refunds", { method: "POST" }); }, }); await loopCtx.step("complete-order", async () => { loopCtx.state.orderId = order.orderId; loopCtx.state.status = "completed"; }); }); // Teardown await ctx.step("finalize", async () => { ctx.state.steps.push(`finished:${result}`); }); }), actions: { getStatus: (c) => ({ status: c.state.status, orderId: c.state.orderId, steps: c.state.steps, }), }, }); export const registry = setup({ use: { orderProcessor } }); registry.start(); // Client usage const client = createClient("http://localhost:6420"); const processor = client.orderProcessor.getOrCreate(["processor-1"]); await processor.send("orders", { orderId: "order-123", amount: 9999 }); await processor.send("control", { action: "cancel" }); const status = await processor.getStatus(); console.log(status); ``` -------------------------------- ### Set Up a Network Server and Fetch Data Source: https://github.com/rivet-dev/rivet/blob/main/website/src/content/docs/agent-os/core.mdx Shows how to start a simple HTTP server inside the VM using Node.js, write the application file, and then fetch data from it using the VM's fetch capability. Requires importing Agent OS core and common software. ```typescript import { AgentOs } from "@rivet/agent-os-core"; import common from "@rivet-dev/agent-os-common"; const vm = await AgentOs.create({ software: [common] }); // Start a server inside the VM await vm.writeFile("/tmp/app.mjs", 'import http from "http"; http.createServer((req, res) => res.end("hello")).listen(3000);'); vm.spawn("node", ["/tmp/app.mjs"]); // Fetch from it const response = await vm.fetch(3000, new Request("http://localhost/")); console.log(await response.text()); await vm.dispose(); ``` -------------------------------- ### Run Filesystem Server Source: https://github.com/rivet-dev/rivet/blob/main/examples/agent-os/README.md Starts the server for the 'filesystem' example, which covers directory operations, file stats, moving, deleting, and mount configuration within the VM. Run this in one terminal. ```bash pnpm filesystem:server ``` -------------------------------- ### Setup and Start Rivet Registry Source: https://context7.com/rivet-dev/rivet/llms.txt Sets up the Rivet registry with the defined actors and starts the application. This is the entry point for the Rivet system. ```typescript export const registry = setup({ use: { inventory, order, orderList } }); registry.start(); ``` -------------------------------- ### Run Network Server Source: https://github.com/rivet-dev/rivet/blob/main/examples/agent-os/README.md Starts the server for the 'network' example, enabling an HTTP server within the VM, fetching from it, and creating preview URLs. Run this in one terminal. ```bash pnpm network:server ``` -------------------------------- ### Run Processes Server Source: https://github.com/rivet-dev/rivet/blob/main/examples/agent-os/README.md Starts the server for the 'processes' example, which demonstrates running shell commands and spawning processes within the VM. Execute this in one terminal. ```bash pnpm processes:server ``` -------------------------------- ### Start Rivet Registry in Auto Mode Source: https://github.com/rivet-dev/rivet/blob/main/website/src/content/docs/general/runtime-modes.mdx Use `registry.start()` for the simplest setup. It starts the server, serves static files, and runs actors automatically. ```typescript registry.start() ``` -------------------------------- ### Run Filesystem Client Source: https://github.com/rivet-dev/rivet/blob/main/examples/agent-os/README.md Executes the client for the 'filesystem' example. This connects to the server to interact with the VM's filesystem. Use this in a separate terminal after starting the server. ```bash pnpm filesystem ``` -------------------------------- ### Clone Repository and Navigate to Example Source: https://github.com/rivet-dev/rivet/blob/main/website/src/content/posts/2025-05-28-building-linear-agents-in-node-js-and-rivet-full-walkthrough-and-starter-kit/page.mdx Clone the Rivet engine repository and change directory to the linear-agent-starter example. ```bash git clone https://github.com/rivet-dev/engine.git cd rivet/examples/linear-agent-starter ``` -------------------------------- ### Start Registry Source: https://github.com/rivet-dev/rivet/blob/main/website/src/content/docs/general/registry-configuration.mdx Provides different methods to start or serve your RivetKit registry depending on your runtime environment. Use `start()` for typical server environments, `serve()` for serverless functions, and `startRunner()` for specific runner setups. ```typescript import { actor, setup } from "rivetkit"; const myActor = actor({ state: {}, actions: {} }); const registry = setup({ use: { myActor } }); registry.start(); ``` ```typescript import { actor, setup } from "rivetkit"; const myActor = actor({ state: {}, actions: {} }); const registry = setup({ use: { myActor } }); export default registry.serve(); ``` ```typescript import { Hono } from "hono"; import { actor, setup } from "rivetkit"; const myActor = actor({ state: {}, actions: {} }); const registry = setup({ use: { myActor } }); const app = new Hono(); app.all("/api/rivet/*", (c) => registry.handler(c.req.raw)); export default app; ``` ```typescript import { actor, setup } from "rivetkit"; const myActor = actor({ state: {}, actions: {} }); const registry = setup({ use: { myActor } }); registry.startRunner(); ``` -------------------------------- ### Environment Configuration Examples Source: https://github.com/rivet-dev/rivet/blob/main/website/src/content/docs/clients/swiftui.mdx Examples showing how to configure the Rivet client using .rivetKit modifier with either an endpoint string or a custom client instance. ```APIDOC ## Concepts ### Environment Configuration Call `.rivetKit(endpoint:)` or `.rivetKit(client:)` once at the root of your view tree: ```swift // With endpoint string (recommended for most apps) @main struct MyApp: App { var body: some Scene { WindowGroup { ContentView() .rivetKit(endpoint: "https://my-namespace:pk_...@api.rivet.dev") } } } // With custom client (for advanced configuration) @main struct MyApp: App { private let client = RivetKitClient( config: try! ClientConfig(endpoint: "https://api.rivet.dev", token: "pk_...") ) var body: some Scene { WindowGroup { ContentView() .rivetKit(client: client) } } } ``` When using `.rivetKit(endpoint:)`, the client is created once and cached per endpoint. When using `.rivetKit(client:)`, store the client as a property on `App` (not inside `body`) since SwiftUI can call `body` multiple times. ``` -------------------------------- ### Clone and Run AI-Generated Actor Example Source: https://github.com/rivet-dev/rivet/blob/main/examples/ai-generated-actor/README.md Clone the Rivet repository, navigate to the AI-generated actor example directory, install dependencies, and run the development server. ```sh git clone https://github.com/rivet-dev/rivet.git cd rivet/examples/ai-generated-actor pnpm install pnpm dev ```