Properties

name

string

The (read-only) name for this app.

The default app's name is "[DEFAULT]".

Examples

// The default app's name is "[DEFAULT]"
firebase.initializeApp(defaultAppConfig);
console.log(firebase.app().name);  // "[DEFAULT]"
// A named app's name is what you provide to initializeApp()
var otherApp = firebase.initializeApp(otherAppConfig, "other");
console.log(otherApp.name);  // "other"

options

non-null Object

The (read-only) configuration options for this app. These are the original parameters given in firebase.initializeApp().

Example

var app = firebase.initializeApp(config);
console.log(app.options.credential === config.credential);  // true
console.log(app.options.databaseURL === config.databaseURL);  // true

Methods

auth

auth() returns firebase.auth.Auth

Gets the Auth service for the current app.

Returns

non-null firebase.auth.Auth 

Example

var auth = app.auth();
// The above is shorthand for:
// var auth = firebase.auth(app);

database

database(url) returns firebase.database.Database

Gets the Database service for the current app. You can also access a secondary database instance by including the URL for the database's root location.

Parameter

url

Optional

string

Optional URL of the Firebase Realtime Database instance you're trying to get. This URL must point to the database's root.

Returns

non-null firebase.database.Database 

Examples

// Get the Database service for the current app
var database = app.database();
// Get the Database service for a specific URL
var secondaryDatabase = app.database(URL);

delete

delete() returns firebase.Promise containing void

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

Returns

non-null firebase.Promise containing void An empty promise fulfilled when the app has been deleted.

Example

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

messaging

messaging() returns firebase.messaging.Messaging

Gets the Messaging service for the current app.

Returns

non-null firebase.messaging.Messaging 

Example

var messaging = app.messaging();
// The above is shorthand for:
// var messaging = firebase.messaging(app);

storage

storage(url) returns firebase.storage.Storage

Gets the Storage service for the current app, optionally initialized with a custom storage bucket.

Parameter

url

Optional

string

The gs:// url to your Firebase Storage Bucket. If not passed, uses the app's default Storage Bucket.

Returns

non-null firebase.storage.Storage 

Examples

var storage = app.storage();
// The above is shorthand for:
// var storage = firebase.storage(app);
var storage = app.storage("gs://your-app.appspot.com");