A Supabase staging environment is a second Supabase project with its own URL, keys, Auth settings and database, built from the same migrations as production and filled with test records instead of customer rows. For one founder with one live app, two projects and a gated release path are enough; Supabase Branching suits several changes in flight.

Supabase staging environment: the four pieces that keep it apart from production

A Supabase staging environment needs four things kept apart from production: its own project and database, its own keys and settings, seed data instead of customer rows, and a release path where staging gets each change first and production waits for an explicit step. Missing any one, staging can still touch live data.

If you are still deciding what a staging environment is for and whether a small app needs one yet, start there; this page assumes the app is live on one Supabase project and you want a second one beside it. Supabase’s Managing Environments guide covers managing multiple Supabase environments with database migrations and GitHub Actions, and its model has three tiers: a local database per developer, a staging project fed by the develop branch, and production fed by main. The table below maps each piece to what it means on Supabase.

PieceWhat it means on SupabaseWhy it matters
Three isolated environmentsSeparate databases, credentials and configuration for development, staging and production; on Supabase, staging is a second projectRoutine tests should not change real customer records or trigger live transactions
Environment configuration separationSeparate variables, databases and keys, plus a documented configuration inventory; on Supabase, the staging URL, publishable key, secret key, Auth redirect URLs and Edge Function secretsA test run that holds live keys can reach real customers’ data and payments
Staging seed dataA seed script you can rerun, filling staging with realistic test records that hold nothing sensitive; on Supabase, supabase/seed.sqlWithout records, the flows a release touches cannot be tried before production
Staging deployment and production promotionAutomated staging deployment and an explicit promotion step for production; on Supabase, a staging workflow on one branch and production on anotherA repeatable release path removes reliance on one person’s manual routine

The keys row needs the most care. Separate env vars for staging and production mean the staging build carries the staging project’s URL and publishable key, and the secret key (the legacy service_role key on older projects) sits only on staging servers, because a secret key bypasses Row Level Security on whichever project issued it. Supabase staging and production should then share nothing but the migration files in Git.

What goes wrong when staging shares production’s database

Each missing piece fails in its own way, and none of the failures announce themselves.

We audited 21 third-party apps in June and July 2026, and at least 17 of them had no deploy gate, as did all 5 of the apps we run ourselves: every push ships straight to production with nothing checking it first. Those 21 apps were picked for review, so the 17 describes that group and is not a rate for AI-built apps in general.

The Supabase staging database that is really production

A staging build, or a second deployment, whose variables still hold the production Supabase URL and keys is a second frontend writing to the live database. A branch changes which code runs; the variables attached to the deployment decide which database it reaches. On Vercel, for example, Production, Preview and branch-specific values are separate settings, and a change applies only to new deployments, so an old build keeps the values it was built with. The result is a dev app writing to the production database while its label says staging. A preview per branch has the same problem unless its variables point elsewhere, which is what a preview shares with production in practice. Before you test anything, read the Supabase URL each environment holds in your host’s settings; on Vercel, Vercel’s environment variables docs explain the Production, Preview and branch-specific values.

Replit’s own announcement describes the single-database setup across a whole platform. On July 21, 2025, after a user reported that Replit’s agent had deleted a production database, Replit wrote that “Until now, Replit apps used a single database for both development and live customer data, making it challenging to safely test and deploy updates”, and announced separate development and production databases. Its first deployment under the new setup “creates a production database with a fresh schema but no data”. The lesson we take from it: a test environment is only as separate as the credentials and the database it is given.

Live keys in a test environment

A staging build that holds the secret key, a live payment key or a production webhook URL can change real records and trigger real charges, even when every line of code is test code. Testing with live credentials can affect real customer data and transactions, whatever the build is called. With one database for dev and prod, the question of how test code wrote to the production database has a short answer: nothing told it where else to go. The risk of one set of keys for every environment is the same on any stack.

An empty staging database nobody can test on

The opposite failure is a schema-only staging project with no users, no roles and no records, so the workflows a release touches never run before production. An empty staging system gives the team little opportunity to test realistic workflows. A seed script fixes it, and realistic fake data for staging covers how to generate records that look like your customers without being them.

Who sets this up depends on how the app is built and who ships to it. A founder can do it alone with the CLI when one person ships and the schema already lives in migrations. A freelancer suits a one-time retrofit where someone has to write the GitHub Actions workflow and hand it back. Agencies make sense when staging is one part of a larger rebuild. A fixed-scope service like ours fits when staging has to arrive together with the other release and data controls before a launch or an investor review.

If the app has paying users and every schema change is first tried on them, start with a free audit: a video call where we talk through your release path with you and weigh up two projects against Branching for your app. In the Production Hardening Sprint, our engineers provide development, staging and production with separate databases, credentials and configuration, separate the variables and keys and document the configuration inventory, provide a repeatable seed script with realistic non-sensitive test records, and automate staging deployment and require an explicit promotion step for production. The implementation follows your stack.

How to retrofit staging onto a live Supabase project

Staging is added to a live Supabase project in six steps: capture the production schema as migrations, create an empty second project, apply the migrations to it, recreate the keys and settings Supabase does not copy, seed test records, then point one non-production build at it. Production keeps running untouched throughout.

Production stays connected exactly as it is until staging is proven, and no customer data is copied at any point. The commands below come from Supabase’s CLI reference and its Managing Environments guide, quoted as documented, not run for this page. Here is how to separate staging and production environments on a project that is already live:

  1. 01 Capture the production schema as migrations: link the CLI to production, run supabase db pull and commit the file it writes. A local database per developer, the third tier in Supabase's guide, can come later.
  2. 02 Create a new, empty Supabase project for staging and note its project ref.
  3. 03 Link the CLI to the staging ref, check the pending list with a dry run, then apply the migrations with supabase db push.
  4. 04 Set up again what the new project does not inherit: Auth URLs and providers, SMTP, Storage buckets, Edge Function secrets and scheduled jobs; then point every webhook at staging and compare extensions with production.
  5. 05 Seed staging from supabase/seed.sql with test accounts for every role and at least two ordinary users.
  6. 06 Point one non-production build at the staging URL and publishable key, and leave the production variables alone.

Capture the production schema as migrations first

Link the CLI to the production project and run supabase db pull. On a project whose schema was built in the dashboard, it writes the live schema into supabase/migrations/<timestamp>_remote_schema.sql; commit that file before any other change. The command needs Docker Desktop or another running Docker daemon, because it starts a local Postgres container to diff the remote schema. After the baseline, a change someone makes in the dashboard is captured with supabase db diff --linked -f <name>, which diffs your migration files against the linked project and saves the difference as a new migration. Projects that have been on Supabase for a long time can hit permission denied for table _type on db pull; the Troubleshooting section of the same guide gives the fix, a set of grant statements on the graphql schema run from the SQL Editor. Moving every dashboard habit into files is its own job, and the database migration checklist covers it for any stack.

Create the staging project and apply the migrations

Create a new, empty project for staging; Supabase’s guide says a project already modified to reflect production’s schema can’t be used, because the CLI would reapply those changes. The project ref, the identifier the Supabase CLI asks for, is the string in each project’s dashboard URL, https://supabase.com/dashboard/project/<project-id>. Then apply the migrations, with the commands as Supabase’s CLI reference documents them:

supabase link --project-ref <staging-ref>
supabase db push --dry-run
supabase db push
supabase migration list

The --dry-run flag prints the migrations that would be applied and does not apply them, and supabase migration list shows whether the migration version is up to date on both the local and the remote database. Production and staging have different refs, and relinking to the right one before every push is the step people get wrong.

Recreate the keys and settings a second project does not copy

A second project starts with its own URL and keys, and the migration files carry none of your Auth, SMTP or secret settings across. Database webhooks are the exception: each one is a trigger, so supabase db pull writes it into the migration with its production target URL. Each row below is set again or checked for staging, never left with live values.

SettingWhere it livesWhat staging needs
Project URL and API keysThe project’s Connect dialogThe staging URL and publishable key in the staging build; the secret key only on staging servers
Site URL and redirect URLsAuthentication, URL Configuration page; the Site URL starts as http://localhost:3000The staging domain, so confirmation and reset emails land on staging
Auth providers (OAuth client credentials)The project’s Auth provider settings, and config.toml for the local stackTest credentials for each provider, with the staging callback allowed
Custom SMTPAuthentication settings pageA sender for staging; without custom SMTP, Auth delivers only to addresses in the project’s team
Storage buckets and their filesDashboard, SQL or client librariesThe same bucket names, holding test files only
Edge Function secretsDashboard or supabase secrets set --env-file .envTest payment keys and staging endpoints; names may not start with SUPABASE_
Scheduled jobsRows in the cron.job table; jobs can be created by SQL or the dashboard’s Cron screenJobs re-created deliberately, calling staging functions
Database webhooksTriggers built on the pg_net extension, created in the dashboard or by SQLEach webhook’s target URL checked and pointed at a staging endpoint
ExtensionsDatabase page in the dashboard, or SQLThe same extensions as production, compared list against list

Payment keys go in test mode on staging. Written down with the values each environment holds, this table becomes your configuration inventory. One caution on buckets: Supabase’s CLI reference says the legacy diff engine can miss changes to storage buckets, so compare the bucket list by eye after the first push.

Seed staging with test records, never customer rows

Supabase runs supabase/seed.sql after all migrations, the first time you run supabase start and every time you run supabase db reset; more files can be listed under [db.seed] with sql_paths in config.toml. The Supabase seed SQL file should hold data inserts only, with no schema statements, as Supabase’s seeding guide recommends. For the hosted staging project, supabase db push takes an --include-seed flag that includes the seed data from your config. Seed every role the app has and at least two ordinary users, so you can test Supabase RLS with two users before a release. A production export is never the seed, however convenient it looks.

Automate staging, then gate production with GitHub Actions

Supabase’s guide sets out one GitHub Actions workflow per environment: pushes to develop run supabase db push against staging, and a merge from develop to main deploys to production after the staging migration has been checked. The staging job reads three values from repository secrets:

on:
  push:
    branches: [develop]
jobs:
  deploy:
    runs-on: ubuntu-latest
    env:
      SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
      SUPABASE_DB_PASSWORD: ${{ secrets.STAGING_DB_PASSWORD }}
      SUPABASE_PROJECT_ID: ${{ secrets.STAGING_PROJECT_ID }}
    steps:
      - uses: actions/checkout@v4
      - uses: supabase/setup-cli@v1
      - run: supabase link --project-ref $SUPABASE_PROJECT_ID
      - run: supabase db push

The production workflow is the same on main with the PRODUCTION_DB_PASSWORD and PRODUCTION_PROJECT_ID secrets. The merge to main is the explicit step. A required reviewer on a GitHub environment adds a second one, but GitHub’s deployment environments page says that on the Free, Pro and Team plans, required reviewers work only on public repositories. Take a Supabase backup before the push to production, and keep a release readiness checklist for the parts of the release that are not the database.

Lovable, Bolt and Replit apps on Supabase

Lovable retired its Test and Live environments for Cloud projects on October 5, 2026; every Cloud project now runs on a single database, and the drafts that replace Test and Live “don’t provide a second database”, as Lovable’s environments page puts it. A Lovable project connected to your own Supabase links to one Supabase project at a time. For Lovable, Bolt or Replit apps connected to Supabase, a Git branch alone does not create a second backend; the variables of each deployment decide which project it reaches. A workable Lovable Cloud environment strategy for dev, staging and prod therefore runs on your own Supabase, using the steps above: migrations in Git, a staging project that receives them first, and a rollback plan ready before the production push. If the app still runs on Lovable Cloud, this path starts with moving off Lovable Cloud.

Two Supabase projects or Supabase Branching

Two Supabase projects suit one founder with one staging lane: the second project costs nothing within the Free plan’s two active projects and runs its own compute on paid plans. Supabase Branching suits several changes in flight, giving each branch its own Supabase instance, and is not included in the Free plan.

OptionWho it suitsWhat it costsWhat data it starts withPlan required
Two projectsOne founder or a small team with one staging laneFree plan: up to 2 active projects, paused after 1 week of inactivity; paid plans: additional projects from $10 a monthNo data: schema from your migrations, records from your seedAny plan
Branching, preview branchSeveral changes in flight, one per pull requestNo fixed fee; from $0.01344 per branch, per hour on Micro computeNo data or storage objects by default; settings and Edge Functions cloned from the base project; schema built from your repository’s migrations on a GitHub-connected branchPro, Team or Enterprise (not included in Free)
Branching, persistent branchA long-lived staging or QA laneThe same hourly branch computeThe same as a preview branchThe same plans

Prices checked on October 20, 2026, against Supabase’s pricing page and its Branching usage docs.

Supabase Branching gives each branch its own Supabase instance and API credentials; a branch starts with the base project’s Auth, Storage and other settings and its Edge Functions, while Auth secrets such as OAuth provider secrets and SMTP passwords get placeholder values. That makes Supabase database branching less work to keep in step than a second project, but branch compute is billed outside the Spend Cap and compute credits do not apply to it. The other limits and prices sit in what each Supabase plan includes. We’d keep one staging lane until two people are shipping schema changes in the same week.

How to prove staging is isolated before you trust it

Staging is proven isolated when a test action in it leaves no trace in production: a signup, a file upload and a function call made from the staging build appear only in the staging project’s dashboard, the seed runs on a clean database, and production changes only through the promotion step.

Run these five checks once after the retrofit and again after any change to variables or secrets, and keep the evidence each one asks for.

  1. 01 From the staging build, sign up a test user, upload a file and call one Edge Function, then confirm all three appear in the staging dashboard and none in production. Keep a screenshot of each.
  2. 02 List every variable and secret per environment, on the host and in Supabase, and confirm no production value is set on a staging target. Keep the list.
  3. 03 Reset staging, run the seed on the clean database, then sign in as two seeded users and walk the core flows. Keep the reset log.
  4. 04 Push a migration to the staging branch, confirm it lands on staging only, then show production waiting for the explicit step. Keep both workflow runs.
  5. 05 Record the date, the two project refs and the results in one note.

In the sprint, deliverable 7.1 is verified this way: verify service isolation and perform a staging action without a production side effect; deliverable 7.4 is verified by deploying a change to staging, then demonstrating the production promotion gate. How these checks sit beside the other release controls is covered in devops for startups.

Common questions about staging on Supabase

Can I set up automated staging environments on Supabase hosting for every Git branch, and how does that affect CI/CD flow?

Yes, with Supabase Branching on a paid plan: each pull request can get a preview branch with its own Supabase instance and API credentials, built from the migrations in your repository. Migrations then run on the branch first, and merging it into the base project runs Supabase’s deployment workflow to production; preview branches are deleted when the pull request is merged or closed.

How many environments are there?

For a Supabase app, Supabase’s Managing Environments guide works with three: a local database per developer, a staging project and production. A small app can start with the two hosted ones and add the local tier later.

How to clear db in Supabase?

On a staging project, supabase db reset --linked drops every user-created entity in the linked database and rebuilds it from your local migrations, then runs the seed unless you pass --no-seed. Check which project the CLI is linked to before you run it, and never run it against production.

When should a founder get help setting up Supabase staging?

Get help when the app has paying users and schema changes still go straight to the live project, or when nobody can say which keys each build holds. At AxonBuild we weigh up your release path with you in a free audit before anything is changed.