On this page

Vercel

Keep a Vercel project's environment variables in sync with your StitchDB project: API URL, anon key, service_role key and Postgres URLs.

Link a Vercel project and StitchDB writes the connection details into its environment variables. When you rotate the API keys, linked projects get the new keys straight away; they apply on the next deployment.

  1. Create an access token at vercel.com/account/tokens, scoped to the team that owns the project.
  2. In your project, open Integrations › Vercel and choose Link a Vercel project.
  3. Paste the token, choose Find projects, then pick the team, the Vercel project, the framework and the environments.

The token is stored encrypted. Only project owners and administrators can link, change or disconnect.

#Variables

  • <prefix>STITCHDB_URL and <prefix>STITCHDB_ANON_KEY: API URL and anon key, readable in browser code. Always.
  • STITCHDB_URL and STITCHDB_ANON_KEY: the same for server code, when you use a framework prefix.
  • STITCHDB_SERVICE_ROLE_KEY: the service_role key (bypasses Row Level Security), if you turn it on.
  • DATABASE_URL and DIRECT_URL: Postgres through the pooler, transaction mode (6543) and session mode (5432), for ORMs such as Prisma and Drizzle, if you turn it on.

The prefix follows the framework: NEXT_PUBLIC_ (Next.js), VITE_, PUBLIC_ (SvelteKit, Astro), NUXT_PUBLIC_, EXPO_PUBLIC_, REACT_APP_, or none. Secrets are saved as sensitive variables in Vercel (not readable back) unless you include Development, where Vercel only allows encrypted ones.

#Disconnect

Disconnect stops the sync. Tick Also delete the variables to remove the ones StitchDB wrote; variables you added yourself are never touched.

#API

The same with the Management API (projects:write):

Terminal
curl -X POST https://stitchdb.com/platform/v1/projects/<ref>/integrations/vercel \
  -H "Authorization: Bearer $STITCHDB_TOKEN" -H "Content-Type: application/json" \
  -d '{ "token": "<vercel token>", "team_id": "team_…", "vercel_project_id": "prj_…",
        "targets": ["production", "preview"], "prefix": "NEXT_PUBLIC_", "database_url": true }'

GET lists links, PATCH …/vercel/<id> changes one, POST …/vercel/<id>/sync writes again, DELETE …/vercel/<id>?remove_variables=true disconnects.

Was this helpful?