Skip to content

Latest commit

 

History

History
371 lines (241 loc) · 13 KB

app.md

File metadata and controls

371 lines (241 loc) · 13 KB

Project: /docs/reference/js/_project.yaml Book: /docs/reference/_book.yaml page_type: reference

{% comment %} DO NOT EDIT THIS FILE! This is generated by the JS SDK team, and any local changes will be overwritten. Changes should be made in the source code at https://github.com/firebase/firebase-js-sdk {% endcomment %}

app package

Firebase App

This package coordinates the communication between the different Firebase components

Functions

FunctionDescription
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.
initializeServerApp(options, config)Creates and initializes a FirebaseServerApp instance.The FirebaseServerApp is similar to FirebaseApp, but is intended for execution in server side rendering environments only. Initialization will fail if invoked from a browser environment.See Add Firebase to your app and Initialize multiple projects for detailed documentation.

Interfaces

InterfaceDescription
FirebaseAppA FirebaseApp holds the initialization information for a collection of services.Do not call this constructor directly. Instead, use initializeApp() to create an app.
FirebaseAppSettingsConfiguration options given to initializeApp()
FirebaseOptionsFirebase 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.
FirebaseServerAppA FirebaseServerApp holds the initialization information for a collection of services running in server environments.Do not call this constructor directly. Instead, use initializeServerApp() to create an app.
FirebaseServerAppSettingsConfiguration options given to initializeServerApp()

Variables

VariableDescription
SDK_VERSIONThe current SDK version.

function(app, ...)

deleteApp(app) {:#deleteapp_cf608e1}

Renders this app unusable and frees the resources of all associated services.

Signature:

exportdeclarefunctiondeleteApp(app: FirebaseApp): Promise<void>;

Parameters

ParameterTypeDescription
appFirebaseApp

Returns:

Promise<void>

Example

deleteApp(app).then(function(){console.log("App deleted successfully");}).catch(function(error){console.log("Error deleting app:",error);});

function()

getApps() {:#getapps}

A (read-only) array of all initialized apps.

Signature:

exportdeclarefunctiongetApps(): FirebaseApp[];

Returns:

FirebaseApp[]

initializeApp() {:#initializeapp}

Creates and initializes a FirebaseApp instance.

Signature:

exportdeclarefunctioninitializeApp(): FirebaseApp;

Returns:

FirebaseApp

function(libraryKeyOrName, ...)

registerVersion(libraryKeyOrName, version, variant) {:#registerversion_f673248}

Registers a library's name and version for platform logging purposes.

Signature:

exportdeclarefunctionregisterVersion(libraryKeyOrName: string,version: string,variant?: string): void;

Parameters

ParameterTypeDescription
libraryKeyOrNamestring
versionstringCurrent version of that library.
variantstringBundle variant, e.g., node, rn, etc.

Returns:

void

function(logCallback, ...)

onLog(logCallback, options) {:#onlog_fd46eae}

Sets log handler for all Firebase SDKs.

Signature:

exportdeclarefunctiononLog(logCallback: LogCallback|null,options?: LogOptions): void;

Parameters

ParameterTypeDescription
logCallbackLogCallback | nullAn optional custom log handler that executes user code whenever the Firebase SDK makes a logging call.
optionsLogOptions

Returns:

void

function(logLevel, ...)

setLogLevel(logLevel) {:#setloglevel_697d53a}

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:

exportdeclarefunctionsetLogLevel(logLevel: LogLevelString): void;

Parameters

ParameterTypeDescription
logLevelLogLevelString

Returns:

void

function(name, ...)

getApp(name) {:#getapp_1eaaff4}

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:

exportdeclarefunctiongetApp(name?: string): FirebaseApp;

Parameters

ParameterTypeDescription
namestringOptional name of the app to return. If no name is provided, the default is "[DEFAULT]".

Returns:

FirebaseApp

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) {:#initializeapp_cb2f5e1}

Creates and initializes a FirebaseApp instance.

See Add Firebase to your app and Initialize multiple projects for detailed documentation.

Signature:

exportdeclarefunctioninitializeApp(options: FirebaseOptions,name?: string): FirebaseApp;

Parameters

ParameterTypeDescription
optionsFirebaseOptionsOptions to configure the app's services.
namestringOptional name of the app to initialize. If no name is provided, the default is "[DEFAULT]".

Returns:

FirebaseApp

The initialized app.

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) {:#initializeapp_079e917}

Creates and initializes a FirebaseApp instance.

Signature:

exportdeclarefunctioninitializeApp(options: FirebaseOptions,config?: FirebaseAppSettings): FirebaseApp;

Parameters

ParameterTypeDescription
optionsFirebaseOptionsOptions to configure the app's services.
configFirebaseAppSettingsFirebaseApp Configuration

Returns:

FirebaseApp

initializeServerApp(options, config) {:#initializeserverapp_30ab697}

Creates and initializes a FirebaseServerApp instance.

The FirebaseServerApp is similar to FirebaseApp, but is intended for execution in server side rendering environments only. Initialization will fail if invoked from a browser environment.

See Add Firebase to your app and Initialize multiple projects for detailed documentation.

Signature:

exportdeclarefunctioninitializeServerApp(options: FirebaseOptions|FirebaseApp,config: FirebaseServerAppSettings): FirebaseServerApp;

Parameters

ParameterTypeDescription
optionsFirebaseOptions | FirebaseAppFirebase.AppOptions to configure the app's services, or a a FirebaseApp instance which contains the AppOptions within.
configFirebaseServerAppSettingsFirebaseServerApp configuration.

Returns:

FirebaseServerApp

The initialized FirebaseServerApp.

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: string
close