website/src/content/docs/actors/quickstart/supabase.mdx
Set up a Rivet project locally that runs on Supabase Edge Functions. The @rivetkit/supabase package wires the WebAssembly runtime for you.
The CLI runs the local Rivet engine as a bundled native binary, so Docker is only needed for Supabase itself. A Supabase project is only needed to deploy.
</Step> <Step title="Create the Function">npx supabase functions new rivet
Add the packages used by the function:
npm install rivetkit @rivetkit/supabase
Call serve from @rivetkit/supabase. It loads the WebAssembly runtime and serves the Rivet handler.
import { actor } from "rivetkit";
import { serve, setup } from "@rivetkit/supabase";
const counter = actor({
state: { count: 0 },
actions: {
increment: (c, amount = 1) => {
c.state.count += amount;
return c.state.count;
},
},
});
// `setup` returns a typed registry, so a client can type itself with
// `typeof registry`.
export const registry = setup({ use: { counter } });
await serve(registry);
Start Rivet. The CLI runs the local engine, spawns supabase functions serve for you, and populates the connection values:
npx @rivetkit/cli dev --provider supabase
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="Call the Actor">Connect to your actor from a client. This connects directly to the local engine on http://localhost:6420:
import { createClient } from "rivetkit/client";
import type { registry } from "./supabase/functions/rivet/index";
const client = createClient<typeof registry>("http://localhost:6420");
const counter = client.counter.getOrCreate(["my-counter"]);
const count = await counter.increment(3);
console.log("New count:", count);
See the JavaScript client documentation for more information.
</Step> <Step title="Deploy">Ready to ship? See Deploying to Supabase Functions.
</Step> </Steps>