Core React Native Firebase implementation providing foundation for all Firebase services across iOS and Android platforms
—
Firebase app initialization, configuration, and lifecycle management functionality. These functions provide control over Firebase app instances in React Native applications.
Creates and initializes a new Firebase app instance with the provided configuration options.
/**
* Initializes a Firebase app with the provided options and name
* @param options - Options to configure the services used in the app
* @param name - The optional name of the app to initialize ('[DEFAULT]' if omitted)
* @returns Promise resolving to the initialized Firebase app
*/
function initializeApp(options: FirebaseAppOptions, name?: string): Promise<FirebaseApp>;
/**
* Initializes a Firebase app with the provided options and config
* @param options - Options to configure the services used in the app
* @param config - The optional config for your firebase app
* @returns Promise resolving to the initialized Firebase app
*/
function initializeApp(options: FirebaseAppOptions, config?: FirebaseAppConfig): Promise<FirebaseApp>;Usage Examples:
import { initializeApp } from '@react-native-firebase/app';
// Initialize default app
const defaultApp = await initializeApp({
apiKey: 'AIzaSyDdVgKwhZl0sTTTLZ7iTmt1r3N2cJLnaDk',
authDomain: 'my-project.firebaseapp.com',
projectId: 'my-project',
appId: '1:12345678901:android:abc123def456'
});
// Initialize named app
const secondaryApp = await initializeApp({
apiKey: 'different-api-key',
projectId: 'secondary-project',
appId: 'secondary-app-id'
}, 'secondary');
// Initialize with config
const configuredApp = await initializeApp({
apiKey: 'api-key',
projectId: 'project-id',
appId: 'app-id'
}, {
name: 'configured',
automaticDataCollectionEnabled: false,
automaticResourceManagement: true
});Retrieves an existing Firebase app instance by name.
/**
* Retrieves an instance of a Firebase app
* @param name - The optional name of the app to return ('[DEFAULT]' if omitted)
* @returns The requested Firebase app instance
*/
function getApp(name?: string): FirebaseApp;Usage Examples:
import { getApp } from '@react-native-firebase/app';
// Get default app
const defaultApp = getApp();
console.log(defaultApp.name); // '[DEFAULT]'
// Get named app
const secondaryApp = getApp('secondary');
console.log(secondaryApp.name); // 'secondary'Returns an array of all currently initialized Firebase app instances.
/**
* Gets the list of all initialized apps
* @returns An array of all initialized Firebase apps
*/
function getApps(): FirebaseApp[];Usage Examples:
import { getApps } from '@react-native-firebase/app';
// Get all initialized apps
const allApps = getApps();
console.log(`Total apps: ${allApps.length}`);
allApps.forEach(app => {
console.log(`App: ${app.name}, Project: ${app.options.projectId}`);
});Renders a Firebase app unusable and frees up all associated resources.
/**
* Renders this app unusable and frees the resources of all associated services
* @param app - The app to delete
* @returns Promise that resolves when the app is deleted
*/
function deleteApp(app: FirebaseApp): Promise<void>;Usage Examples:
import { deleteApp, getApp, SDK_VERSION } from '@react-native-firebase/app';
// Delete a specific app
const myApp = getApp('secondary');
await deleteApp(myApp);
console.log('App deleted successfully');
// Get SDK version
console.log('Firebase SDK Version:', SDK_VERSION);Registers a library's name and version for platform logging purposes. Note: This function is only supported on Web and will throw an error on React Native.
/**
* Registers a library's name and version for platform logging purposes
* @param libraryKeyOrName - Library name or key
* @param version - Library version
* @param variant - Library variant (optional)
* @returns Promise that resolves when registration is complete
* @throws Error on React Native platforms (only supported on Web)
*/
function registerVersion(libraryKeyOrName: string, version: string, variant?: string): Promise<void>;Usage Examples:
import { registerVersion } from '@react-native-firebase/app';
try {
// This will throw an error on React Native
await registerVersion('my-library', '1.0.0', 'react-native');
} catch (error) {
console.log('registerVersion is only supported on Web');
}The current version of the React Native Firebase SDK.
/**
* The current SDK version string
*/
const SDK_VERSION: string;Usage Examples:
import { SDK_VERSION } from '@react-native-firebase/app';
console.log('React Native Firebase version:', SDK_VERSION);
// Useful for debugging or logging
console.log(`App initialized with RNFirebase ${SDK_VERSION}`);The traditional Firebase v8-style API is also available through the default export:
import firebase from '@react-native-firebase/app';
// Access default app
const app = firebase.app();
// Initialize new app (traditional style)
const newApp = await firebase.initializeApp(options, name);
// Get app (traditional style)
const myApp = firebase.app('myAppName');
// Get all apps
const apps = firebase.apps;App management functions may throw Firebase-specific errors:
import { getApp } from '@react-native-firebase/app';
try {
const app = getApp('nonexistent');
} catch (error) {
console.log(error.code); // Firebase error code
console.log(error.message); // Error message
}Once you have a Firebase app instance, you can access its properties and methods:
import { getApp } from '@react-native-firebase/app';
const app = getApp();
// Read-only properties
console.log(app.name); // App name
console.log(app.options); // App configuration options
// Settable properties
app.automaticDataCollectionEnabled = false;
// Methods
await app.delete(); // Delete the app
const utils = app.utils(); // Get utils moduleInstall with Tessl CLI
npx tessl i tessl/npm-react-native-firebase--app