TypeScript

Modular API import patterns for TypeScript, where the generated type definitions live, and the compare:types process used for Auth.

Prerequisites

  • A React Native or Expo app with TypeScript enabled. Official setup: React Native TypeScript documentation.
  • @react-native-firebase/app installed and native config completed per Getting Started (Android google-services.json, iOS GoogleService-Info.plist, Expo config plugin, or React Native CLI setup).
  • The product package you import (this page uses @react-native-firebase/auth as the example): npm install --save @react-native-firebase/auth or yarn add @react-native-firebase/auth, then rebuild native apps if you just added the package.

React Native Firebase ships TypeScript declarations for every module. Modular types and helpers are exported from each package root (for example @react-native-firebase/auth). v26 removed the namespaced API and the Firebase*Types namespaces from the packages listed in Migrating to v26, so use the modular names shown below.

Modular API

Import modular helpers and types from the package root. This example is a complete React component that listens for auth state:

tsx
import { useEffect, useState } from 'react';
import { getAuth, onAuthStateChanged, type User } from '@react-native-firebase/auth';

function App() {
  const [user, setUser] = useState<User | null>(null);

  useEffect(() => {
    const authInstance = getAuth();
    return onAuthStateChanged(authInstance, setUser);
  }, []);

  if (!user) {
    return null;
  }

  return user.email;
}

Historical note: Migrating to v25 covers the Auth breaking changes made in v25 (the FirebaseAuthTypes deprecation, provider helpers, async isSignInWithEmailLink, and other firebase-js-sdk alignment updates). The FirebaseAuthTypes namespace was then removed in v26; import User, Auth, and the other modular types from @react-native-firebase/auth instead.

Where definitions live

Published types are built to packages/<module>/dist/typescript/ (for example packages/auth/dist/typescript/lib/index.d.ts). Source lives under packages/<module>/lib/ as TypeScript (.ts) since the v25 package migrations.

Modular Auth source: packages/auth/lib/index.ts.

Public API reference (generated from source JSDoc): reference API.

Definitions per module

Each package exports its own types from the package root. Examples:

ModuleModular types (import from package root)
AuthUser, Auth, UserCredential, OAuthProvider, …
FirestoreFirestore, DocumentReference, QuerySnapshot, DocumentData, …
App CheckAppCheck, AppCheckTokenResult, …

For Auth v25 alignment details and intentional firebase-js-sdk differences, see the Auth compare:types triage knowledge document and yarn compare:types auth registry.