Skip to main content
Many vibe-coded apps start with Firebase because it’s easy to set up. Supabase gives you the same ease-of-use but on a PostgreSQL backend you can query with SQL, with Row Level Security that’s more transparent, and without vendor lock-in. This guide covers migrating Firestore (NoSQL) to Supabase (PostgreSQL) and Firebase Auth to Supabase Auth.
This is a data migration — it requires changes to your app’s code alongside the data move. Budget time for both the migration and testing.

What this guide covers

  • Exporting data from Firestore
  • Designing a PostgreSQL schema for your Firestore collections
  • Migrating data with the Supabase import tool
  • Swapping Firebase Auth for Supabase Auth
  • Updating your frontend code

Step 1 — Export Firestore data

In Firebase Console:
# Using Firebase CLI
firebase firestore:export gs://your-bucket/firestore-export

# Download to local
gsutil -m cp -r gs://your-bucket/firestore-export ./firestore-export
Or use the firestore-export-import npm package for JSON output:
npx firestore-export-import export firestore-backup.json

Step 2 — Design your Supabase schema

Firestore is document-based; Supabase is relational. You’ll need to map collections to tables. Example Firestore structure:
/users/{userId}
  name: string
  email: string
  createdAt: timestamp

/posts/{postId}
  title: string
  content: string
  authorId: string (ref to /users)
  createdAt: timestamp
Equivalent Supabase schema:
create table users (
  id uuid primary key default gen_random_uuid(),
  name text not null,
  email text unique not null,
  created_at timestamptz default now()
);

create table posts (
  id uuid primary key default gen_random_uuid(),
  title text not null,
  content text,
  author_id uuid references users(id) on delete cascade,
  created_at timestamptz default now()
);

-- Enable Row Level Security
alter table users enable row level security;
alter table posts enable row level security;

-- Example RLS policies
create policy "Users can read own data" on users
  for select using (auth.uid() = id);

create policy "Anyone can read posts" on posts
  for select using (true);
Run this schema in the Supabase SQL Editor.

Step 3 — Import your data

Convert your Firestore JSON export to CSV or SQL insert statements, then import to Supabase:
import json
import csv

# Convert Firestore export to CSV
with open('firestore-backup.json') as f:
    data = json.load(f)

with open('users.csv', 'w') as f:
    writer = csv.DictWriter(f, fieldnames=['id', 'name', 'email', 'created_at'])
    writer.writeheader()
    for doc_id, doc in data['users'].items():
        writer.writerow({
            'id': doc_id,
            'name': doc['name'],
            'email': doc['email'],
            'created_at': doc['createdAt']
        })
Then import in Supabase Dashboard → Table Editor → Import CSV.

Step 4 — Migrate Firebase Auth users

Firebase Auth users can’t be transferred directly, but Supabase has a Firebase Auth migration guide:
  1. Export Firebase Auth users:
    firebase auth:export users.json --format=json
    
  2. Use the Supabase Firebase migration script to import users with their UIDs preserved (so existing user references in your data stay valid).

Step 5 — Update your frontend code

Replace Firebase SDK calls with Supabase equivalents:
import { initializeApp } from 'firebase/app';
import { getFirestore, collection, getDocs } from 'firebase/firestore';
import { getAuth, signInWithEmailAndPassword } from 'firebase/auth';

const db = getFirestore(app);
const auth = getAuth(app);

// Read data
const querySnapshot = await getDocs(collection(db, 'posts'));
const posts = querySnapshot.docs.map(doc => ({ id: doc.id, ...doc.data() }));

// Sign in
await signInWithEmailAndPassword(auth, email, password);

Step 6 — Deploy with Nometria

Once your code is updated and tested locally against Supabase:
  1. Connect your repo to Nometria via GitHub
  2. Add your Supabase credentials as environment variables
  3. Deploy

Deploy to AWS

How Nometria provisions your production infrastructure.

Post-migration checklist

  • All Firestore collections mapped to Supabase tables
  • Data imported and verified (row counts match)
  • Firebase Auth users migrated with UIDs preserved
  • Frontend code updated to use Supabase SDK
  • RLS policies set correctly
  • App tested end-to-end on Supabase
  • Firebase project billing paused or deleted