The Firebase JS SDK is now in BETA!
This EAP site is no longer maintained. See the official Firebase Documentation site for the latest documentation and information about the Firebase JS SDK.

Home > @firebase/app > getApp

getApp() function

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:

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 app
const app = getApp();

Example 2

// Return a named app
const otherApp = getApp("otherApp");