Firebase Auth with Capacitor 3

Firebase Capacitor JS

I recently built my first native iOS app with Svelte, Capacitor, and Firebase (coming soon!). The stack is a breeze to work with, but I ran into a snag getting Firebase to work in the iOS builds. Non of the firebase calls were returning. Luckily, a friendly redditor pointed out the problem: Firebase auth needs to be initialized manually on iOS, or else signInWithPopUp and signInWithRedirect will hold things up - even when using a capacitor plugin that authorizes natively like capacitor-firebase-authentication. So here’s my code to manually authorize on iOS:

function whichAuth() {
  let auth
  if (Capacitor.isNativePlatform()) {
    auth = initializeAuth(app, {
      persistence: indexedDBLocalPersistence
  } else {
    auth = getAuth()
  return auth

export const auth = whichAuth()

With this code, my app is working flawlessly - and development has been a joy!

Harry Herskowitz

Harry is a web developer and programmer with a focus on using technology to empower local artists and communities

Recommended for you