How to Migrate from Firebase to Supabase: Complete Step-by-Step Guide | Dev Tool Rank

How to Migrate from Firebase to Supabase: Complete Step-by-Step Guide

Tutorial ยท 7 min read ๐Ÿ”„ Affiliate Links

๐Ÿ” Want the best deal? Check current prices and availability.

Compare Prices โ†’

When you buy through links on our site, we may earn a commission.

How to Migrate from Firebase to Supabase: Complete Step-by-Step Guide

Firebase and Supabase look like the same product from a distance. Both give you auth, a database, file storage, and serverless functions behind a client SDK. The resemblance stops the moment you look at what's underneath. Firebase hands you a proprietary document store with its own query language and security rule syntax. Supabase hands you Postgres, and everything else is a layer on top of it.

That difference is why the migration question keeps coming up. Teams hit a Firestore query they can't express, a bill that jumps after a viral week, or a reporting requirement that needs SQL joins. Moving is not a weekend project, but it's also not the rewrite people fear. Most of the work is mechanical once you understand the mapping between the two systems.

This guide walks through that mapping and the actual migration sequence. Nothing here assumes you're starting from scratch โ€” it assumes you have a live Firebase app with real users and real data, and you'd rather not lose either.

Firebase vs Supabase: what each one actually gives you

Before touching a single line of code, it helps to see the two platforms side by side. They overlap in roughly 60% of their surface area, and the gaps on either side are where migration pain lives.

CapabilityFirebaseSupabase
Primary databaseFirestore (document/NoSQL) or Realtime DatabasePostgres 15+ (relational, full SQL)
Query modelLimited compound queries, no joins, no aggregatesFull SQL: joins, CTEs, window functions, views
AuthEmail/password, OAuth, phone, anonymous, MFAEmail/password, OAuth, phone, anonymous, MFA, SAML SSO
AuthorizationSecurity Rules (custom DSL)Row Level Security policies (SQL)
File storageCloud Storage bucketsS3-compatible Storage buckets
RealtimeFirestore snapshot listenersRealtime channels (Postgres changes, broadcast, presence)
Serverless functionsCloud Functions (Node.js, Python)Edge Functions (Deno) + Postgres triggers
Push notificationsFirebase Cloud MessagingNone built in
Analytics / crash reportingGoogle Analytics, CrashlyticsNone built in
Remote configFirebase Remote ConfigNone built in
HostingFirebase Hosting with CDNNo first-party CDN hosting
Local developmentEmulator Suitesupabase start (full local stack in Docker)
Vendor lock-inHigh โ€” proprietary APIs, no SQL exportLow โ€” standard Postgres, pg_dump works

Two rows matter more than the rest. The first is the query model. Firestore forces you to denormalize aggressively and duplicate data because you can't join. Postgres lets you normalize and let the database do the work. That's a design shift, not a syntax swap, and it's where most of your thinking time goes.

The second is lock-in. Supabase runs on vanilla Postgres, so if you leave Supabase later you take a pg_dump with you and point it at RDS, Neon, or a box in a closet. Leaving Firebase means exporting JSON and rebuilding your data model from scratch. If portability is part of why you're migrating, Supabase is the more honest choice.

Concept mapping: Firebase to Supabase

Keep this table open while you work. Nearly every Firestore concept has a Postgres counterpart, though a few are one-to-many.

FirebaseSupabase equivalent
CollectionTable
DocumentRow
Document IDPrimary key (often uuid or text)
SubcollectionSeparate table with a foreign key
FieldColumn
onSnapshot() listenersupabase.channel().on('postgres_changes', ...)
Security RulesRLS policies
Cloud Function (HTTPS)Edge Function
Cloud Function (Firestore trigger)Postgres trigger + pg_net or Database Webhooks
Firebase Storage pathStorage object key inside a bucket
Custom Claimsapp_metadata in the JWT, or a profiles table
Firebase UIDauth.users.id (UUID)
Cloud Schedulerpg_cron

The subcollection row is the one that trips people up. A Firestore subcollection under /users/{uid}/orders/{orderId} becomes an orders table with a user_id column and a foreign key. It sounds trivial. When you have nested subcollections three levels deep, it stops being trivial, and you should plan the schema on paper before you write any migration code.

Step 1: Audit what you're actually running

You can't migrate what you haven't counted. Open the Firebase console and pull numbers for:

  • Auth users โ€” total count, and which sign-in providers are active. Phone auth and SAML are the two that need extra attention.
  • Firestore collections โ€” list every top-level and subcollection, plus approximate document counts.
  • Storage buckets โ€” total size in GB and object count.
  • Cloud Functions โ€” each function's trigger type (HTTPS, Firestore, Auth, Scheduled, Pub/Sub).
  • Integrations you depend on โ€” FCM, Remote Config, Crashlytics, A/B Testing, App Check.

That last bullet is the reality check. Supabase has no FCM, no Remote Config, no Crashlytics, and no A/B testing. If your app leans on push notifications, you're keeping Firebase for that piece or moving to OneSignal. If you rely on Remote Config for feature flags, you're replacing it with something like PostHog, LaunchDarkly, or a feature_flags table you write yourself.

Be honest here. A partial migration that keeps Firebase for messaging and Supabase for data is a completely reasonable end state, and it's better than a full migration that ships a broken notification system.

Step 2: Create the Supabase project and design the schema

Sign up and create a project at Check Supabase Current Deal โ†’. Pick a region close to your users โ€” this is the one decision that's genuinely hard to reverse later, since moving a live Postgres database across regions means downtime.

On the free tier you get 500 MB of database space, 1 GB of file storage, 5 GB of egress, and 50,000 monthly active users. That's fine for staging. Before you cut production over, you'll want Pro at $25/month per project, which raises those to 8 GB, 100 GB, and 250,000 MAU respectively.

Now design the schema. Don't try to mirror Firestore's document shapes. Firestore users typically end up with users, profiles, orders, order_items, and a handful of join tables. Write it as SQL migrations using the Supabase CLI:

supabase init

supabase migration new initial_schema

Put your CREATE TABLE statements in the generated file, then run supabase db push. Keeping migrations in version control from day one saves you a lot of grief when the schema inevitably changes.

Two conventions worth adopting immediately: use uuid primary keys so you can reuse Firebase UIDs during migration, and add created_at timestamptz default now() to every table. You will want it later.

Step 3: Migrate auth users (including password hashes)

This is the step people assume is impossible. It isn't โ€” Firebase exports password hashes in a format Supabase can import, and users keep their existing passwords without a reset email.

Export from Firebase:

firebase auth:export users.json --format=json --project your-project-id

Then use the community migration scripts from the supabase-community/firebase-to-supabase repository. The auth subdirectory contains a script that reads the exported JSON and inserts users through the Supabase Admin API, preserving the Firebase UID as the Supabase user ID.

You'll need these environment variables:

FIREBASE_PROJECT_ID=

FIREBASE_CLIENT_EMAIL=

FIREBASE_PRIVATE_KEY=

SUPABASE_URL=

SUPABASE_SERVICE_ROLE_KEY=

Firebase stores passwords using scrypt with parameters that Supabase Auth understands. When a migrated user logs in for the first time, Supabase verifies the scrypt hash and silently re-hashes the password to bcrypt. From the user's perspective, nothing happened.

Caveats worth knowing before you run this:

  • Phone-only users have no password hash. They'll need to re-verify via OTP on first login to Supabase.
  • Custom claims don't transfer automatically. Read them from the export and write them into a profiles table or into Supabase's app_metadata.
  • Run it against staging first. The script is idempotent-ish but not bulletproof, and a botched import against production auth is a bad afternoon.

Step 4: Export Firestore and load it into Postgres

There's no automated Firestore-to-Postgres converter, and you should distrust anyone selling one. Document stores and relational schemas don't map cleanly, and the transformation is where your domain knowledge matters.

Start with a managed export:

gcloud firestore export gs://your-bucket/firestore-export

That gives you a set of LevelDB-format files. To work with them, load them

๐Ÿ” Want the best deal? Check current prices and availability.

Compare Prices โ†’
D

Dev Tool Rank Editorial Team

We're a team of tech enthusiasts who test and review tools so you don't have to. Our reviews are independent โ€” we only recommend what we'd actually use ourselves.