Skip to main content

Migrate from Supabase

NaijaBase is API-compatible with Supabase. Most apps can migrate in under an hour by swapping environment variables and updating the SDK import.

Why migrate?

  • Data sovereignty — your data stays in Lagos, Nigeria (NDPA 2023 compliant)
  • Lower latency — servers in Nigeria instead of AWS us-east-1 or eu-west-1
  • Nigerian payment integration — Paystack built-in, no custom webhooks needed
  • Local support — support team in Nigerian timezone (WAT)

Step-by-step migration

Step 1 — Export your Supabase data

In the Supabase dashboard, go to Settings → Database → Backups and download a full backup, or use pg_dump:

pg_dump \
"postgresql://postgres:[password]@db.[project-ref].supabase.co:5432/postgres" \
--no-owner \
--no-acl \
-F c \
-f supabase_backup.dump

Step 2 — Create a NaijaBase project

Sign up at app.naijabase.dev and create a new project. Note your:

  • Project URL
  • Anon key (nb_anon_...)
  • Service key (nb_service_...)

Step 3 — Import your data

In your NaijaBase project dashboard, go to Database → Restore and upload supabase_backup.dump, or restore via pg_restore:

pg_restore \
--no-owner \
--no-acl \
-d "postgresql://postgres:[password]@db.[your-project].naijabase.dev:5432/postgres" \
supabase_backup.dump

Step 4 — Update environment variables

Old (Supabase)New (NaijaBase)
NEXT_PUBLIC_SUPABASE_URLNEXT_PUBLIC_NAIJABASE_URL
NEXT_PUBLIC_SUPABASE_ANON_KEYNEXT_PUBLIC_NAIJABASE_ANON_KEY
SUPABASE_SERVICE_ROLE_KEYNAIJABASE_SERVICE_KEY
SUPABASE_DB_URLNAIJABASE_DB_URL
# .env.local (before)
NEXT_PUBLIC_SUPABASE_URL=https://abcdef.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJ...
SUPABASE_SERVICE_ROLE_KEY=eyJ...

# .env.local (after)
NEXT_PUBLIC_NAIJABASE_URL=https://api.naijabase.dev
NEXT_PUBLIC_NAIJABASE_ANON_KEY=nb_anon_...
NAIJABASE_SERVICE_KEY=nb_service_...

Step 5 — Update SDK imports

// Before
import { createClient } from '@supabase/supabase-js'
const supabase = createClient(
process.env.NEXT_PUBLIC_SUPABASE_URL,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY
)

// After
import { createClient } from '@naijabase/js'
const nb = createClient(
process.env.NEXT_PUBLIC_NAIJABASE_URL,
process.env.NEXT_PUBLIC_NAIJABASE_ANON_KEY
)

Install the NaijaBase SDK:

npm remove @supabase/supabase-js
npm install @naijabase/js

Step 6 — Update storage bucket policies

If you had public buckets in Supabase, re-create them in NaijaBase:

// Re-create each bucket
await nb.storage.createBucket('avatars', { public: true })
await nb.storage.createBucket('documents', { public: false })

Step 7 — Test and verify

Run your test suite. Key things to verify:

  • Auth flows (sign-up, sign-in, sign-out, password reset)
  • Database reads and writes
  • Row Level Security policies
  • Storage uploads and downloads
  • Realtime subscriptions
  • Edge functions (if any)

API differences

FeatureSupabaseNaijaBase
SDK package@supabase/supabase-js@naijabase/js
Anon key prefixeyJ... (JWT)nb_anon_...
Service key prefixeyJ... (JWT)nb_service_...
Auth endpoint/auth/v1//auth/v1/ ✓ same
REST endpoint/rest/v1//rest/v1/ ✓ same
Storage endpoint/storage/v1//storage/v1/ ✓ same
Realtime endpoint/realtime/v1//realtime/v1/ ✓ same
Edge functionsDeno-basedNode.js-based
PaymentsManual integrationPaystack built-in
Data regionAWS us-east-1 / eu-westLagos, Nigeria
ComplianceSOC2, HIPAA (add-on)NDPA 2023

Edge functions differences

Supabase edge functions run on Deno. NaijaBase edge functions run on Node.js. If you have edge functions, you will need to:

  1. Remove Deno-specific imports (e.g. import { serve } from "https://deno.land/std/http/server.ts")
  2. Replace with Node.js/Express equivalents
  3. Use require or import from npm packages
// Supabase (Deno)
import { serve } from "https://deno.land/std@0.177.0/http/server.ts"
serve((req) => new Response("Hello"))

// NaijaBase (Node.js)
module.exports = async (req, res) => {
res.json({ message: 'Hello' })
}

RLS policies

Your existing RLS policies work without changes. The auth.uid() function, auth.role(), and auth.jwt() helpers behave identically.

Getting help