Skip to Content

Use your data on Supabase

≈ 5 min · you will have an app that reads and writes your Supabase project, connected by signing in and allowing access, with no keys to paste.

The app still has its own database for everything it manages. Supabase is an extra data source: the customers, products and orders you already have.

1. Connect Supabase

  1. Open the project and go to Connect › Data sources.
  2. Click Connect Supabase, sign in to Supabase and allow access.
  3. Pick the Supabase project and click Use this project.

manh.run sets three secrets for the app: SUPABASE_URL, SUPABASE_PUBLISHABLE_KEY, SUPABASE_SECRET_KEY. A running app gets them at once, with no redeploy.

Only the project owner can connect or disconnect. Disconnecting removes the three secrets and the app stops reading Supabase.

2. Read and write from server code

app/customers/get.ts
import { supabase } from "manh/supabase"; import { fail } from "manh/errors"; export default async (c: any, { query }: any) => { const { data, error } = await supabase .from("customers") .select("id, name, phone") .ilike("name", `%${query.q ?? ""}%`) .range(0, 49); if (error) fail(424, `Supabase: ${error.message}`, "SUPABASE_ERROR"); return { data }; };

supabase is written like Supabase’s own library: from(table).select / insert / update / upsert / delete, filters eq, in, ilike, order, range, plus rpc(name, args). Every call returns { data, error }.

Call Storage and Edge Functions with supabaseFetch(path, options). It adds the key for you.

3. Let the agent work with your tables

The agent can list your tables and columns and run SQL on the connected project: create tables, add columns, load sample rows. It asks you before deleting data.

Notes

  • Server code uses the secret key, which bypasses Row Level Security. The handler is the gate: keep export const access and filter by the signed-in user.
  • Pages (.tsx) never call Supabase directly. They call the app’s handlers like any other data, so keys never reach the browser.
  • App users still sign in with app/auth.ts, not Supabase Auth.
  • If code calls supabase before you connect, the call fails with 424 SUPABASE_NOT_CONNECTED. The app keeps running.

Next steps

Last updated