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(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 to info , errors are logged, but debug and verbose logs are not). |
function(name, ...) | |
getApp(name) | Retrieves a FirebaseApp 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 a FirebaseApp instance.See Add Firebase to your app and Initialize multiple projects for detailed documentation. |
initializeApp(options, config) | Creates and initializes a FirebaseApp instance. |
Interfaces
Interface | Description |
---|---|
FirebaseApp | A FirebaseApp holds the initialization information for a collection of services.Do not call this constructor directly. Instead, use initializeApp() to create an app. |
FirebaseAppSettings | Configuration options given to initializeApp() |
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. |
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:
export declare function deleteApp(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:
export declare function getApps(): FirebaseApp[];
Returns:
initializeApp()
Creates and initializes a FirebaseApp instance.
Signature:
export declare function initializeApp(): FirebaseApp;
Returns:
function(libraryKeyOrName, ...)
registerVersion(libraryKeyOrName, version, variant)
Registers a library's name and version for platform logging purposes.
Signature:
export declare function registerVersion(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:
export declare function onLog(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 to info
, errors are logged, but debug
and verbose
logs are not).
Signature:
export declare function setLogLevel(logLevel: LogLevelString): void;
Parameters
Parameter | Type | Description |
---|---|---|
logLevel | LogLevelString |
Returns:
void
function(name, ...)
getApp(name)
Retrieves a FirebaseApp 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:
export declare function getApp(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 app
const app = getApp();
Example 2
// Return a named app
const otherApp = getApp("otherApp");
function(options, ...)
initializeApp(options, name)
Creates and initializes a FirebaseApp instance.
See Add Firebase to your app and Initialize multiple projects for detailed documentation.
Signature:
export declare function initializeApp(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.
Example 1
// Initialize default app
// Retrieve your own options values by adding a web app on
// https://console.firebase.google.com
initializeApp({
apiKey: "AIza....", // Auth / General Use
authDomain: "YOUR_APP.firebaseapp.com", // Auth with popup/redirect
databaseURL: "https://YOUR_APP.firebaseio.com", // Realtime Database
storageBucket: "YOUR_APP.appspot.com", // Storage
messagingSenderId: "123456789" // Cloud Messaging
});
Example 2
// Initialize another app
const otherApp = 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:
export declare function initializeApp(options: FirebaseOptions, config?: FirebaseAppSettings): FirebaseApp;
Parameters
Parameter | Type | Description |
---|---|---|
options | FirebaseOptions | Options to configure the app's services. |
config | FirebaseAppSettings | FirebaseApp Configuration |
Returns:
SDK_VERSION
The current SDK version.
Signature:
SDK_VERSION: string