app package Stay organized with collections Save and categorize content based on your preferences.
Firebase App
This package coordinates the communication between the different Firebase components
Functions
| Function | Description |
|---|---|
| function(app, ...) | |
| deleteApp(app) | Renders this app unusable and frees the resources of all associated services. |
| function() | |
| getApps() | A (read-only) array of all initialized apps. |
| initializeApp() | Creates and initializes a FirebaseApp instance. |
| function(config, ...) | |
| initializeServerApp(config) | Creates and initializes aFirebaseServerApp instance. |
| function(libraryKeyOrName, ...) | |
| registerVersion(libraryKeyOrName, version, variant) | Registers a library's name and version for platform logging purposes. |
| function(logCallback, ...) | |
| onLog(logCallback, options) | Sets log handler for all Firebase SDKs. |
| function(logLevel, ...) | |
| setLogLevel(logLevel) | Sets log level for all Firebase SDKs.All of the log types above the current log level are captured (i.e. if you set the log level toinfo, errors are logged, butdebug andverbose logs are not). |
| function(name, ...) | |
| getApp(name) | Retrieves aFirebaseApp instance.When called with no arguments, the default app is returned. When an app name is provided, the app corresponding to that name is returned.An exception is thrown if the app being retrieved has not yet been initialized. |
| function(options, ...) | |
| initializeApp(options, name) | Creates and initializes aFirebaseApp instance.SeeAdd Firebase to your app andInitialize multiple projects for detailed documentation. |
| initializeApp(options, config) | Creates and initializes a FirebaseApp instance. |
| initializeServerApp(options, config) | Creates and initializes aFirebaseServerApp instance.TheFirebaseServerApp is similar toFirebaseApp, but is intended for execution in server side rendering environments only. Initialization will fail if invoked from a browser environment.SeeAdd Firebase to your app andInitialize multiple projects for detailed documentation. |
Interfaces
| Interface | Description |
|---|---|
| FirebaseApp | AFirebaseApp holds the initialization information for a collection of services.Do not call this constructor directly. Instead, useinitializeApp() to create an app. |
| FirebaseAppSettings | Configuration options given toinitializeApp() |
| FirebaseOptions | Firebase configuration object. Contains a set of parameters required by services in order to successfully communicate with Firebase server APIs and to associate client data with your Firebase project and Firebase application. Typically this object is populated by the Firebase console at project setup. See also:Learn about the Firebase config object. |
| FirebaseServerApp | AFirebaseServerApp holds the initialization information for a collection of services running in server environments.Do not call this constructor directly. Instead, useinitializeServerApp() to create an app. |
| FirebaseServerAppSettings | Configuration options given toinitializeServerApp() |
Variables
| Variable | Description |
|---|---|
| SDK_VERSION | The current SDK version. |
function(app, ...)
deleteApp(app)
Renders this app unusable and frees the resources of all associated services.
Signature:
exportdeclarefunctiondeleteApp(app:FirebaseApp):Promise<void>;Parameters
| Parameter | Type | Description |
|---|---|---|
| app | FirebaseApp |
Returns:
Promise<void>
Example
deleteApp(app).then(function(){console.log("App deleted successfully");}).catch(function(error){console.log("Error deleting app:",error);});function()
getApps()
A (read-only) array of all initialized apps.
Signature:
exportdeclarefunctiongetApps():FirebaseApp[];Returns:
initializeApp()
Creates and initializes a FirebaseApp instance.
Signature:
exportdeclarefunctioninitializeApp():FirebaseApp;Returns:
function(config, ...)
initializeServerApp(config)
Creates and initializes aFirebaseServerApp instance.
Signature:
exportdeclarefunctioninitializeServerApp(config?:FirebaseServerAppSettings):FirebaseServerApp;Parameters
| Parameter | Type | Description |
|---|---|---|
| config | FirebaseServerAppSettings | OptionalFirebaseServerApp settings. |
Returns:
The initializedFirebaseServerApp.
Exceptions
If invoked in an unsupported non-server environment such as a browser.
IfFirebaseServerAppSettings.releaseOnDeref is defined but the runtime doesn't provide Finalization Registry support.
If theFIREBASE_OPTIONS environment variable does not contain a valid project configuration required for auto-initialization.
function(libraryKeyOrName, ...)
registerVersion(libraryKeyOrName, version, variant)
Registers a library's name and version for platform logging purposes.
Signature:
exportdeclarefunctionregisterVersion(libraryKeyOrName:string,version:string,variant?:string):void;Parameters
| Parameter | Type | Description |
|---|---|---|
| libraryKeyOrName | string | |
| version | string | Current version of that library. |
| variant | string | Bundle variant, e.g., node, rn, etc. |
Returns:
void
function(logCallback, ...)
onLog(logCallback, options)
Sets log handler for all Firebase SDKs.
Signature:
exportdeclarefunctiononLog(logCallback:LogCallback|null,options?:LogOptions):void;Parameters
| Parameter | Type | Description |
|---|---|---|
| logCallback | LogCallback | null | An optional custom log handler that executes user code whenever the Firebase SDK makes a logging call. |
| options | LogOptions |
Returns:
void
function(logLevel, ...)
setLogLevel(logLevel)
Sets log level for all Firebase SDKs.
All of the log types above the current log level are captured (i.e. if you set the log level toinfo, errors are logged, butdebug andverbose logs are not).
Signature:
exportdeclarefunctionsetLogLevel(logLevel:LogLevelString):void;Parameters
| Parameter | Type | Description |
|---|---|---|
| logLevel | LogLevelString |
Returns:
void
function(name, ...)
getApp(name)
Retrieves aFirebaseApp instance.
When called with no arguments, the default app is returned. When an app name is provided, the app corresponding to that name is returned.
An exception is thrown if the app being retrieved has not yet been initialized.
Signature:
exportdeclarefunctiongetApp(name?:string):FirebaseApp;Parameters
| Parameter | Type | Description |
|---|---|---|
| name | string | Optional name of the app to return. If no name is provided, the default is"[DEFAULT]". |
Returns:
The app corresponding to the provided app name. If no app name is provided, the default app is returned.
Example 1
// Return the default appconstapp=getApp();Example 2
// Return a named appconstotherApp=getApp("otherApp");function(options, ...)
initializeApp(options, name)
Creates and initializes aFirebaseApp instance.
SeeAdd Firebase to your app andInitialize multiple projects for detailed documentation.
Signature:
exportdeclarefunctioninitializeApp(options:FirebaseOptions,name?:string):FirebaseApp;Parameters
| Parameter | Type | Description |
|---|---|---|
| options | FirebaseOptions | Options to configure the app's services. |
| name | string | Optional name of the app to initialize. If no name is provided, the default is"[DEFAULT]". |
Returns:
The initialized app.
Exceptions
If the optionalname parameter is malformed or empty.
If aFirebaseApp already exists with the same name but with a different configuration.
Example 1
// Initialize default app// Retrieve your own options values by adding a web app on// https://console.firebase.google.cominitializeApp({apiKey:"AIza....",// Auth / General UseauthDomain:"YOUR_APP.firebaseapp.com",// Auth with popup/redirectdatabaseURL:"https://YOUR_APP.firebaseio.com",// Realtime DatabasestorageBucket:"YOUR_APP.appspot.com",// StoragemessagingSenderId:"123456789"// Cloud Messaging});Example 2
// Initialize another appconstotherApp=initializeApp({databaseURL:"https://<OTHER_DATABASE_NAME>.firebaseio.com",storageBucket:"<OTHER_STORAGE_BUCKET>.appspot.com"},"otherApp");initializeApp(options, config)
Creates and initializes a FirebaseApp instance.
Signature:
exportdeclarefunctioninitializeApp(options:FirebaseOptions,config?:FirebaseAppSettings):FirebaseApp;Parameters
| Parameter | Type | Description |
|---|---|---|
| options | FirebaseOptions | Options to configure the app's services. |
| config | FirebaseAppSettings | FirebaseApp Configuration |
Returns:
Exceptions
IfFirebaseAppSettings.name is defined but the value is malformed or empty.
If aFirebaseApp already exists with the same name but with a different configuration.
initializeServerApp(options, config)
Creates and initializes aFirebaseServerApp instance.
TheFirebaseServerApp is similar toFirebaseApp, but is intended for execution in server side rendering environments only. Initialization will fail if invoked from a browser environment.
SeeAdd Firebase to your app andInitialize multiple projects for detailed documentation.
Signature:
exportdeclarefunctioninitializeServerApp(options:FirebaseOptions|FirebaseApp,config?:FirebaseServerAppSettings):FirebaseServerApp;Parameters
| Parameter | Type | Description |
|---|---|---|
| options | FirebaseOptions |FirebaseApp | Firebase.AppOptions to configure the app's services, or a aFirebaseApp instance which contains theAppOptions within. |
| config | FirebaseServerAppSettings | OptionalFirebaseServerApp settings. |
Returns:
The initializedFirebaseServerApp.
Exceptions
If invoked in an unsupported non-server environment such as a browser.
IfFirebaseServerAppSettings.releaseOnDeref is defined but the runtime doesn't provide Finalization Registry support.
Example
// Initialize an instance of `FirebaseServerApp`.// Retrieve your own options values by adding a web app on// https://console.firebase.google.cominitializeServerApp({apiKey:"AIza....",// Auth / General UseauthDomain:"YOUR_APP.firebaseapp.com",// Auth with popup/redirectdatabaseURL:"https://YOUR_APP.firebaseio.com",// Realtime DatabasestorageBucket:"YOUR_APP.appspot.com",// StoragemessagingSenderId:"123456789"// Cloud Messaging},{authIdToken:"Your Auth ID Token"});SDK_VERSION
The current SDK version.
Signature:
SDK_VERSION:stringExcept as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-07-17 UTC.