πŸš€ Launch mobile apps 10x faster with Next.jsGet NextNative β†’
✨ Features
πŸ”’ Authorization

Firebase Authentication Setup for iOS & Android

πŸ”§ Skip Auth logic to test app without it

Still setting up Firebase Auth? You can skip the sign-in screen and test your app by setting:

// (mobile)/router.tsx
const isSignedInTest = true;

Create a Firebase project

To set up authorization, start by creating a new project in Firebase:

Go your project on Firebase (opens in a new tab) and create a new project.


Create a Firebase project

Update values in .env.local

Take these Firebase Auth config values and paste them in your .env.local


Copy paste to env
Env firebase example

iOS Setup

⚠️

Rename your app before setting up Firebase Authorization for iOS.

1. Register your iOS app

In the Firebase console:

  1. Click Add App β†’ Select iOS
  2. Enter your iOS Bundle ID (e.g. com.yourcompany.yourapp)
  3. (Optional) Add an App nickname
  4. Click Register App

Add an iOS app

2. Download the Firebase config file

Once your iOS app is registered:

  1. Click Download GoogleService-Info.plist
  2. Save it locally – you'll need it in Xcode

Download Firebase config iOS

3. Open iOS project in Xcode

Run the following command:

npx cap open ios

4. Add the config to your project

  1. Drag & drop the GoogleService-Info.plist into Xcode
  2. Select β€œCopy items if needed”
  3. Place it in the root of the app target folder

Put Firebase config iOS

5. Install Firebase SDK via Swift Package Manager

  1. In Xcode: File β†’ Add Packages
  2. Paste:
   https://github.com/firebase/firebase-ios-sdk
  1. Select only the modules you need (e.g. FirebaseAuth)
  2. Click Add Package

Install Firebase package iOS

6. Enable Google Sign-In

  1. Go to Authentication β†’ Sign-in method
  2. Enable Google
  3. Save

πŸ” Re-download GoogleService-Info.plist and replace the old one

7. Enable Apple Sign-In

  1. Go to Authentication β†’ Sign-in method
  2. Enable Apple
  3. Save

8. Configure Custom URL Scheme

  1. In Xcode, open project settings
  2. Select your app under Targets
  3. Go to Info β†’ URL Types
  4. Click βž• and add a new entry
  5. In URL Schemes, paste your REVERSED_CLIENT_ID

(found in GoogleService-Info.plist) 6. Leave other fields empty

This step enables Google login redirect to work

9. Test Login Flow

You can now call:

import { FirebaseAuthentication } from "@capacitor-firebase/authentication";
 
await FirebaseAuthentication.signInWithGoogle();
// or
await FirebaseAuthentication.signInWithApple();

Sign out:

await FirebaseAuthentication.signOut();

You can use SignInScreen.tsx component where all of these is done. It's going to be run by default.

Android Setup

If you don't need Firebase Auth/Notifications in your app at all, go to build.gradle and remove this line:

apply plugin: 'com.google.gms.google-services'
⚠️

Rename your app before setting up Firebase Authorization for Android.

1. Add a new Android app

In the Firebase console:

  1. Click Add App β†’ Select Android
  2. Enter your app’s Package name (e.g. com.yourcompany.appname)
  3. (Optional) Add app nickname
  4. Click Register app

2. Set SHA-1 fingerprint

It's essential to enable Google sign-in.

Open a terminal and run:

macOS/Linux:

keytool -list -v \
-alias androiddebugkey -keystore ~/.android/debug.keystore

Windows:

keytool -list -v \
-alias androiddebugkey -keystore %USERPROFILE%\.android\debug.keystore

It will prompt you to enter a password for the keystore.

The default password for the debug keystore is android. The keytool then prints the fingerprint to the terminal. For example:

Certificate fingerprint: SHA1: DA:39:A3:EE:5E:6B:4B:0D:32:55:BF:EF:95:60:18:90:AF:D8:07:09

Copy it and paste here in Firebase Project Settings for your Android app:


Certificate

3. Download & replace config file

  1. Download the google-services.json file
  2. Place it in:
android/app/google-services.json

4. Enable Google Sign-In

In Firebase Console:

  • Go to Authentication β†’ Sign-in method
  • Enable Google
  • Save

5. Sign in with Google

Use the Capacitor plugin to trigger login:

import { FirebaseAuthentication } from "@capacitor-firebase/authentication";
 
await FirebaseAuthentication.signInWithGoogle();

Sign out:

await FirebaseAuthentication.signOut();

6. Test on real Android device

npx cap open android
⚠️

Use a physical device with Google Play Services. Most emulators don’t support this.

Web

1. Add a new Web app in Firebase

  1. Go to your Firebase project
  2. Click Add App β†’ Select the Web icon
  3. Enter a nickname (e.g. My Web App)
  4. Click Register App

2. Update values in .env.local

⚠️
Skip if already done.

Take these Firebase Auth config values and paste them in your .env.local


Copy paste to env
Env firebase example

NextNative Docs