Gif of small pixel dog running back and forth along the top of the page. His name is Byte.

Firebase Auth with Capacitor 3

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!

More Posts: