Interfaces

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

Optional

admin.app.AppOptions

Optional AppOptions to configure the app's services. If missing they are read from the FIREBASE_CONFIG environment variable which is either a json object or the name of a json file.

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",
  storageBucket: "<BUCKET_NAME>.appspot.com",
  projectId: "<PROJECT_ID>"
});
// Initialize the default app with the Application Default Credentials and
// the options loaded from the `FIREBASE_CONFIG` environment variable.
admin.initializeApp()
// Initialize another app
var otherApp = admin.initializeApp({
  credential: <OTHER_CREDENTIAL>,
  databaseURL: "https://<OTHER_DATABASE_NAME>.firebaseio.com",
  storageBucket: "<BUCKET_NAME>.appspot.com",
  projectId: "<PROJECT_ID>",
  databaseAuthVariableOverride: {
    uid: "some-uid"
  }
}, "otherApp");