Move a Replit database to Supabase

Apps from Replit Agent keep their data in PostgreSQL that Replit runs. Supabase runs PostgreSQL too, so the data moves with the standard tools: pg_dump copies it and pg_restore loads it. The one thing to get right is which of the two Replit databases you copy.

Your Replit data in a database you own

Development or production

Replit Agent sets up the database with separate development and production environments. When you publish, Replit connects the published app to the production database. The DATABASE_URL in your workspace points at the development one, with test data. For a move you want production.

The production database only exists after the first publish. Until then the Database tool lists only Development Database. The first publish creates the production one from the development data.

1. Find the production connection string

Open the Database tool in Replit, pick Production Database and go to Settings. Copy the connection string of the production database. It holds the password, so keep it out of chats and screenshots.

The Database tool in Replit, Settings of the production database, with the connection string hidden

2. Make the dump

Run pg_dump in the Shell in Replit, or on your computer with PostgreSQL 16 or newer.

pg_dump "{{production connection string}}" -Fc -f backup.dump

The -Fc option writes the custom format that pg_restore reads. If you made the dump in Replit, download backup.dump from the file tree.

3. Create the Supabase project

Create a new project at supabase.com in a region close to your users. Then click Connect and copy the Session pooler string. Put your database password in place of [YOUR-PASSWORD].

The Create a new project form in Supabase with the project name, database password and region filled in

4. Load the data

pg_restore --no-owner --no-privileges -d "{{Supabase connection string}}" backup.dump

--no-owner and --no-privileges skip the owners and the access rules of the Replit database. Its roles do not exist in Supabase. Then open the Table Editor in Supabase. You should see your tables with their rows.

5. Point the app at Supabase

Set DATABASE_URL to the Supabase string, in the .env file on your computer and on the new host. Apps from Replit Agent can use the Neon serverless driver, which is made for Neon. Ask your AI tool: "If the code uses the Neon serverless driver, switch it to the pg driver so it works with any PostgreSQL database."

Before you switch

  • Data people save after the dump is not in it. For the final copy, unpublish the app in Publishing first.
  • Keep backup.dump until the new setup has run for a while.
  • Logins move on their own. Replit Auth users are not Supabase users, so people sign up again with the same email address.

Replit database or Supabase

Replit databaseSupabase
DatabasePostgreSQLPostgreSQL
Who runs itReplit, for your appSupabase, in your own account
BillingBy compute time and storage, through ReplitYour Supabase plan
Logins and filesReplit Auth and App StorageSupabase Auth and Storage in the same project

Sources

  1. Replit docs: Manually copy a project to another workspace
  2. Replit docs: Add a database
  3. PostgreSQL docs: pg_dump
  4. PostgreSQL docs: pg_restore
  5. Supabase docs: Migrate from Postgres to Supabase

Read next

Pick your route.

Choose where you are and where you want to go. The guide takes it from there.