Migrate from Firebase Authentication
Move Firebase Authentication users and their scrypt password hashes into Pontive with pontive migrate, check the project's hash parameters before importing, then replace firebase/auth with pontkit.
The steps below use the pontive migrate CLI. Read Migrate to Pontive first
for how runs, dry runs and matching work.
1. What moves and what does not
| Moves | Does not move |
|---|---|
Users from the Admin SDK's listUsers: email and whether it is verified, phone number, display name, photo URL, creation time; disabled users as deactivated; custom claims as private_metadata | Password hashes, unless the service account may read the project's hash configuration (below). Without them, password users use Forgot password at their first sign-in |
| Firebase's modified-scrypt hashes and salts. Their project parameters go on the migration source, never in the file | SMS and TOTP second factors: Firebase exports no secret, so those users enroll again |
Google, GitHub and Apple identities, and OIDC providers (oidc.…) as oidc | Microsoft identities and providers Pontive has no portable type for (Facebook, X, …): those users link by verified email |
The Firebase uid, as legacy subject and external_id | Phone-only and anonymous users (Pontive requires an email); Identity Platform tenants, which are not organizations. Firebase has no organizations |
2. Create the migration source
The exporter uses a service account through GOOGLE_APPLICATION_CREDENTIALS. For listUsers to
return hashes, the account also needs firebaseauth.configs.getHashConfig, which takes a custom IAM
role; without it every password user comes out without a hash, and the export report says so.
Firebase verifies passwords with four project parameters. In the Firebase console, open Authentication, then Users, then the menu above the user list, and Password hash parameters. Save the text it shows to a file and give it to the source:
export PONTIVE_SECRET_KEY=pontive_sk_test_us_... # an admin key of your development instance
npx pontive@latest migrate source create --name "Firebase" --type firebase \
--hash-config firebase-hash.txt # prints msrc_...The file holds the signer key: delete it afterwards. Or give the values one by one, with the signer key in the environment rather than a flag:
FIREBASE_SIGNER_KEY=... npx pontive@latest migrate source create --name "Firebase" --type firebase \
--salt-separator Bw== --rounds 8 --mem-cost 14Pontive stores the signer key encrypted and never returns it, only a four-character preview.
3. Export, then dry run
export GOOGLE_APPLICATION_CREDENTIALS=./service-account.json
npx -p pontive@latest -p firebase-admin pontive migrate export firebase # writes pontive-users.ndjsonfirebase-admin is not installed with pontive, hence -p. Before importing, check the source's
parameters against one user whose password you know, such as a test account:
PONTIVE_SAMPLE_PASSWORD='their password' npx pontive@latest migrate source validate msrc_... \
--file pontive-users.ndjson --email tester@acme.comok means imported passwords will verify; FAILED means a parameter is wrong, and every Firebase
password would fail. Fix it with migrate source update msrc_... --hash-config <file>. Then dry-run:
npx pontive@latest migrate import pontive-users.ndjson --source msrc_...4. Map roles and connections
Firebase has no organizations or roles to map. Map the social identities to the Pontive app's auth connections, or leave a type out and its users link by verified email:
npx pontive@latest migrate import pontive-users.ndjson --source msrc_... \
--identity-connection google=app_...:google \
--identity-connection apple=app_...:appleImport an Apple identity only when your Pontive Apple connection uses the same Apple developer team
as Firebase did, and an oidc one only for the same issuer: their subjects are per team and per
issuer.
5. Apply
npx pontive@latest migrate import pontive-users.ndjson --source msrc_... \
--identity-connection google=app_...:google \
--identity-connection apple=app_...:apple \
--apply --delete-afterFirebase's scrypt is below OWASP's minimum, so each hash is wrapped in argon2id at import and re-hashed natively at the user's first sign-in. Keep the migration source until then: Pontive refuses to delete it, or to remove its parameters, while imported hashes still need them.
6. Swap the SDK
Follow the React quickstart or the Next.js quickstart, then replace each Firebase call:
firebase/auth | pontkit |
|---|---|
signInWithEmailAndPassword, signInWithPopup, FirebaseUI | <Signin /> from @pontive/pontkit-react |
createUserWithEmailAndPassword | <Signup /> |
onAuthStateChanged(auth, …) | useAuthState() (isAuthenticated, resolved), useSession(), or <SignedIn> and <SignedOut> |
auth.currentUser | Auth.getAuthenticatedUser(), Auth from @pontive/oidc-client |
signOut(auth) | Auth.signOut() |
user.getIdToken() | Auth.getCurrentSession()?.access_token |
firebase-admin's verifyIdToken(token) | rs.requireBearer() from @pontive/pontkit-server/resource-server (Protect an API) |
user.uid | the token's sub (usr_…) |
Firestore and Storage security rules read request.auth from Firebase Authentication, which no
longer signs anyone in. Either move those reads and writes behind your server, which verifies the
Pontive token and uses the Admin SDK, or keep the rules by signing the browser in to Firebase with a
custom token your server mints for the Pontive user (npm install firebase-admin jose). With the
claims template carrying the old uid (step 7), rules on request.auth.uid keep matching imported
users:
import { decodeJwt } from "jose";
import { initializeApp, getApps } from "firebase-admin/app";
import { getAuth } from "firebase-admin/auth";
import { pontive } from "@/lib/pontive";
if (getApps().length === 0) initializeApp();
export async function POST() {
const session = await pontive().auth(); // verified by pontkit
if (!session) return new Response("Unauthorized", { status: 401 });
// The imported user's Firebase uid; users created in Pontive have none.
const { legacy_user_id } = decodeJwt(session.accessToken);
const uid = typeof legacy_user_id === "string" ? legacy_user_id : session.user.id;
return Response.json({ token: await getAuth().createCustomToken(uid) });
}The browser then calls signInWithCustomToken(getAuth(), token) from firebase/auth.
7. Cut over
Follow the cutover checklist. For Firebase in particular:
- Export again just before switching and import into the same run with
--run uimp_.... - Set the app's claims template to
{ "legacy_user_id": "{{ user.external_id }}" }if your data or rules key users by Firebase uid. - Turn off sign-ups and Firebase's email templates once the app is on Pontive. Users sign in once more.
npx pontive@latest migrate source get msrc_...shows how many imported passwords are still waiting for their user's first sign-in.
8. Revert
npx pontive@latest migrate revert uimp_... # dry run
npx pontive@latest migrate revert uimp_... --applyUsers who have signed in to Pontive since are kept and listed. See Revert.
Migrate from Clerk
Move Clerk users, password digests, TOTP secrets, social identities and organizations with their roles into Pontive with pontive migrate, then replace Clerk's components and auth() helper with pontkit's.
Migrate from Supabase Auth
Move Supabase Auth users, bcrypt password hashes, TOTP factors and social identities into Pontive with pontive migrate, keep your data in Supabase, and keep Row Level Security policies working through the cutover.