Does Firebase Work With Clerk?
You can use Firebase and Clerk together, but they overlap on authentication—you'll need to choose which handles user auth and integrate them carefully.
Quick Facts
How Firebase Works With Clerk
Firebase and Clerk can coexist in the same project, but since both handle authentication, you need a clear architecture. The typical pattern is using Clerk for authentication and user management (leveraging its superior UI and user experience), while using Firebase Realtime Database or Firestore for data storage and other backend services. After Clerk authenticates a user, you can retrieve their JWT token and use it to authenticate requests to Firebase via custom claims or a secondary token exchange. Alternatively, some teams disable Firebase Auth entirely and use Clerk exclusively for identity, then access Firebase services through authenticated REST calls. The main challenge is syncing user data between systems—Clerk's user object and Firebase's user records need reconciliation, often through webhooks. Performance-wise this adds minimal overhead since both are cloud-native, but you're paying for two separate services and managing two user databases.
Best Use Cases
Clerk + Firestore with JWT Verification
npm install firebase @clerk/backendimport { initializeApp } from 'firebase/app';
import { getFirestore, collection, query, where, getDocs } from 'firebase/firestore';
import { verifyToken } from '@clerk/backend';
const firebaseConfig = { /* your config */ };
const app = initializeApp(firebaseConfig);
const db = getFirestore(app);
// In your API route/function
export async function getUserData(token: string) {
// Verify Clerk JWT
const decoded = await verifyToken(token);
const clerkUserId = decoded.sub;
// Query Firestore using Clerk user ID
const q = query(
collection(db, 'users'),
where('clerkId', '==', clerkUserId)
);
const snapshot = await getDocs(q);
return snapshot.docs[0]?.data();
}Known Issues & Gotchas
User data duplication between Clerk and Firebase
Fix: Use Clerk webhooks to sync user creation/deletion events to Firestore. Store a Clerk user ID in Firebase docs as the source of truth for linking.
JWT token validation complexity
Fix: Use Clerk's built-in token verification libraries (@clerk/backend) instead of manually validating JWTs. For Firebase, exchange Clerk tokens via a callable function.
Firebase Realtime Database doesn't natively support Clerk tokens
Fix: Use Firestore with security rules that validate Clerk JWTs, or route through Cloud Functions to validate Clerk tokens before database access.
Increased costs from dual authentication systems
Fix: Plan your pricing: you'll pay for Clerk auth + Firebase services. For smaller projects, consider Firebase Auth alone.
Alternatives
- •Firebase Auth + Firebase Hosting: Native integration, simpler architecture, but less polished auth UI
- •Auth0 + Firestore: More flexible auth provider with similar SSO capabilities, standard industry choice
- •Supabase + PostgreSQL: Open-source Firebase alternative with built-in auth, single vendor reduces complexity
Resources
Related Compatibility Guides
Explore more compatibility guides