Interface

Namespaces

Properties

apps

static

non-null Array of admin.app.App

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

SDK_VERSION

static

string

The current SDK version.

Methods

app

static

app(name) returns admin.app.App

Retrieves a Firebase app 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.

Parameter

name

Optional

string

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

Returns

non-null admin.app.App The app corresponding to the provided app name. If no app name is provided, the default app is returned.

Examples

// Return the default app
var app = admin.app();
// Return a named app
var otherApp = admin.app("otherApp");

initializeApp

static

initializeApp(options, name) returns admin.app.App

Creates and initializes a Firebase app instance.

See Initialize the SDK and Initialize multiple apps for detailed documentation.

Parameter

options

admin.app.AppOptions

Options to configure the app's services.

Value must not be null.

name

Optional

string

Optional name of the app to initialize. If no name is provided, the default is "[DEFAULT]".

Returns

non-null admin.app.App The initialized app.

Examples

// Initialize default app
admin.initializeApp({
  credential: <CREDENTIAL>,
  databaseURL: "https://<DATABASE_NAME>.firebaseio.com"
});
// Initialize another app
var otherApp = admin.initializeApp({
  credential: <OTHER_CREDENTIAL>,
  databaseURL: "https://<OTHER_DATABASE_NAME>.firebaseio.com",
  databaseAuthVariableOverride: {
    uid: "some-uid"
  }
}, "otherApp");