πŸš€ Launch mobile apps 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

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.nextnative.yourapp)
  3. (Optional) Add app nickname
  4. Click Register app

Download & place config file

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

Enable Google Sign-In

In Firebase Console:

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

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();

Test on real Android device

npx cap open android
⚠️

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


NextNative Docs