Core React Native Firebase implementation providing foundation for all Firebase services across iOS and Android platforms
npx @tessl/cli install tessl/npm-react-native-firebase--app@23.3.0React Native Firebase App is the core foundation package that provides Firebase integration for React Native applications. It serves as the main entry point and manager for all Firebase services, offering both traditional Firebase v8 API compatibility and modern v9+ modular functions. The package handles app initialization, configuration management, cross-platform native bridge functionality, and provides essential utilities for file operations and Google Play Services integration.
npm install @react-native-firebase/app or yarn add @react-native-firebase/appES Modules/TypeScript:
import firebase from '@react-native-firebase/app';
import { initializeApp, getApp, getApps, SDK_VERSION } from '@react-native-firebase/app';CommonJS:
const firebase = require('@react-native-firebase/app').default;
const { initializeApp, getApp, getApps, SDK_VERSION } = require('@react-native-firebase/app');import firebase, { initializeApp, getApp } from '@react-native-firebase/app';
// Access the default app (automatically initialized)
const defaultApp = firebase.app();
console.log(defaultApp.name); // '[DEFAULT]'
// Initialize a secondary app with custom config
const secondaryApp = await initializeApp({
apiKey: 'your-api-key',
authDomain: 'your-project.firebaseapp.com',
projectId: 'your-project-id',
appId: 'your-app-id'
}, 'secondary');
// Get an app instance
const myApp = getApp('secondary');
// Use utils for file operations
const utils = firebase.utils();
console.log(utils.FilePath.DOCUMENT_DIRECTORY);React Native Firebase App is structured around several key components:
firebase.app(), firebase.utils() access patternsinitializeApp, getApp, etc.) for tree-shaking and improved bundlingCore Firebase app initialization, configuration, and lifecycle management. Essential for setting up Firebase in React Native applications.
function initializeApp(options: FirebaseAppOptions, name?: string): Promise<FirebaseApp>;
function initializeApp(options: FirebaseAppOptions, config?: FirebaseAppConfig): Promise<FirebaseApp>;
function getApp(name?: string): FirebaseApp;
function getApps(): FirebaseApp[];
function deleteApp(app: FirebaseApp): Promise<void>;
function registerVersion(libraryKeyOrName: string, version: string, variant?: string): Promise<void>;
const SDK_VERSION: string;Firebase SDK configuration, logging control, and platform-specific settings management.
function setLogLevel(logLevel: LogLevelString): void;
function setReactNativeAsyncStorage(asyncStorage: ReactNativeAsyncStorage): void;
function onLog(logCallback: (params: LogCallbackParams) => void, options?: any): void;Access to native platform data, preferences, and Firebase configuration from React Native.
function metaGetAll(): Promise<{[key: string]: string | boolean}>;
function jsonGetAll(): Promise<{[key: string]: string | boolean}>;
function preferencesGetAll(): Promise<{[key: string]: string | boolean}>;
function preferencesClearAll(): Promise<void>;
function preferencesSetBool(key: string, value: boolean): Promise<void>;
function preferencesSetString(key: string, value: string): Promise<void>;Platform utilities including file path constants, Google Play Services helpers, and Test Lab detection.
interface Utils.Module {
isRunningInTestLab: boolean;
playServicesAvailability: PlayServicesAvailability;
getPlayServicesStatus(): Promise<PlayServicesAvailability>;
promptForPlayServices(): Promise<void>;
makePlayServicesAvailable(): Promise<void>;
resolutionForPlayServices(): Promise<void>;
}
interface Utils.FilePath {
MAIN_BUNDLE: string;
CACHES_DIRECTORY: string;
DOCUMENT_DIRECTORY: string;
EXTERNAL_DIRECTORY: string | null;
EXTERNAL_STORAGE_DIRECTORY: string | null;
TEMP_DIRECTORY: string;
LIBRARY_DIRECTORY: string;
PICTURES_DIRECTORY: string;
MOVIES_DIRECTORY: string;
}interface FirebaseApp {
readonly name: string;
readonly options: FirebaseAppOptions;
automaticDataCollectionEnabled: boolean;
delete(): Promise<void>;
utils(): Utils.Module;
}
interface FirebaseAppOptions {
appId: string;
apiKey?: string;
databaseURL?: string;
projectId: string;
measurementId?: string;
storageBucket?: string;
messagingSenderId?: string;
clientId?: string;
androidClientId?: string;
deepLinkURLScheme?: string;
[name: string]: any;
}
interface FirebaseAppConfig {
name?: string;
automaticDataCollectionEnabled?: boolean;
automaticResourceManagement?: boolean;
}
interface NativeFirebaseError extends Error {
readonly code: string;
readonly message: string;
readonly namespace: string;
readonly nativeErrorCode: string | number;
readonly nativeErrorMessage: string;
}
interface ReactNativeAsyncStorage {
setItem: Function;
getItem: Function;
removeItem: Function;
[key: string]: any;
}
type LogLevelString = 'debug' | 'verbose' | 'info' | 'warn' | 'error' | 'silent';
interface LogCallbackParams {
level: LogLevelString;
message: string;
args: unknown[];
type: string;
}
interface PlayServicesAvailability {
status: PlayServicesAvailabilityStatusCodes;
isAvailable: boolean;
hasResolution: boolean | undefined;
isUserResolvableError: boolean | undefined;
error: string | undefined;
}
enum PlayServicesAvailabilityStatusCodes {
API_UNAVAILABLE = 16,
CANCELED = 13,
DEVELOPER_ERROR = 10,
DRIVE_EXTERNAL_STORAGE_REQUIRED = 1500,
INTERNAL_ERROR = 8,
INTERRUPTED = 15,
INVALID_ACCOUNT = 5,
LICENSE_CHECK_FAILED = 11,
NETWORK_ERROR = 7,
RESOLUTION_REQUIRED = 6,
RESTRICTED_PROFILE = 20,
SERVICE_DISABLED = 3,
SERVICE_INVALID = 9,
SERVICE_MISSING = 1,
SERVICE_MISSING_PERMISSION = 19,
SERVICE_UPDATING = 18,
SERVICE_VERSION_UPDATE_REQUIRED = 2,
SIGN_IN_FAILED = 17,
SIGN_IN_REQUIRED = 4,
SUCCESS = 0,
TIMEOUT = 14,
}