@firebase/app
- Version 0.14.5
- Published
- 401 kB
- 5 dependencies
- Apache-2.0 license
Install
npm i @firebase/appyarn add @firebase/apppnpm add @firebase/appOverview
Firebase App
Remarks
This package coordinates the communication between the different Firebase components
Index
Variables
Functions
Interfaces
Variables
variable SDK_VERSION
const SDK_VERSION: string;- The current SDK version. - Modifiers- @public
 
Functions
function deleteApp
deleteApp: (app: FirebaseApp) => Promise<void>;- Renders this app unusable and frees the resources of all associated services. - Example 1deleteApp(app).then(function() {console.log("App deleted successfully");}).catch(function(error) {console.log("Error deleting app:", error);});- Modifiers- @public
 
function getApp
getApp: (name?: string) => FirebaseApp;- Retrieves a @firebase/app#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. - Parameter name- Optional name of the app to return. If no name is provided, the default is - "[DEFAULT]".- Returns- The app corresponding to the provided app name. If no app name is provided, the default app is returned. - Example 1// Return the default appconst app = getApp();- Example 2// Return a named appconst otherApp = getApp("otherApp");- Modifiers- @public
 
function getApps
getApps: () => FirebaseApp[];- A (read-only) array of all initialized apps. - Modifiers- @public
 
function initializeApp
initializeApp: {    (options: FirebaseOptions, name?: string): FirebaseApp;    (options: FirebaseOptions, config?: FirebaseAppSettings): FirebaseApp;    (): FirebaseApp;};- Creates and initializes a @firebase/app#FirebaseApp instance. - See Add Firebase to your app and Initialize multiple projects for detailed documentation. - Parameter options- Options to configure the app's services. - Parameter name- Optional name of the app to initialize. If no name is provided, the default is - "[DEFAULT]".- Returns- The initialized app. - Throws- If the optional - nameparameter is malformed or empty.- Throws- If a - FirebaseAppalready exists with the same name but with a different configuration.- 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 appconst otherApp = initializeApp({databaseURL: "https://<OTHER_DATABASE_NAME>.firebaseio.com",storageBucket: "<OTHER_STORAGE_BUCKET>.appspot.com"}, "otherApp");- Modifiers- @public
 
- Creates and initializes a FirebaseApp instance. - Parameter options- Options to configure the app's services. - Parameter config- FirebaseApp Configuration - Throws- If FirebaseAppSettings.name is defined but the value is malformed or empty. - Throws- If a - FirebaseAppalready exists with the same name but with a different configuration.- Modifiers- @public
 
- Creates and initializes a FirebaseApp instance. - Modifiers- @public
 
function initializeServerApp
initializeServerApp: {    (        options: FirebaseOptions | FirebaseApp,        config?: FirebaseServerAppSettings    ): FirebaseServerApp;    (config?: FirebaseServerAppSettings): FirebaseServerApp;};- Creates and initializes a @firebase/app#FirebaseServerApp instance. - The - FirebaseServerAppis 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. - Parameter options- Firebase.AppOptionsto configure the app's services, or a a- FirebaseAppinstance which contains the- AppOptionswithin.- Parameter config- Optional - FirebaseServerAppsettings.- Returns- The initialized - FirebaseServerApp.- Throws- If invoked in an unsupported non-server environment such as a browser. - Throws- If FirebaseServerAppSettings.releaseOnDeref is defined but the runtime doesn't provide Finalization Registry support. - Example 1// 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"});- Modifiers- @public
 
- Creates and initializes a @firebase/app#FirebaseServerApp instance. - Parameter config- Optional - FirebaseServerAppsettings.- Returns- The initialized - FirebaseServerApp.- Throws- If invoked in an unsupported non-server environment such as a browser. - Throws- If FirebaseServerAppSettings.releaseOnDeref is defined but the runtime doesn't provide Finalization Registry support. - Throws- If the - FIREBASE_OPTIONSenvironment variable does not contain a valid project configuration required for auto-initialization.- Modifiers- @public
 
function onLog
onLog: (logCallback: LogCallback | null, options?: LogOptions) => void;- Sets log handler for all Firebase SDKs. - Parameter logCallback- An optional custom log handler that executes user code whenever the Firebase SDK makes a logging call. - Modifiers- @public
 
function registerVersion
registerVersion: (    libraryKeyOrName: string,    version: string,    variant?: string) => void;- Registers a library's name and version for platform logging purposes. - Parameter library- Name of 1p or 3p library (e.g. firestore, angularfire) - Parameter version- Current version of that library. - Parameter variant- Bundle variant, e.g., node, rn, etc. - Modifiers- @public
 
function setLogLevel
setLogLevel: (logLevel: LogLevelString) => void;- 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- debugand- verboselogs are not).- Modifiers- @public
 
Interfaces
interface FirebaseApp
interface FirebaseApp {}- A @firebase/app#FirebaseApp holds the initialization information for a collection of services. - Do not call this constructor directly. Instead, use initializeApp() to create an app. - Modifiers- @public
 
property automaticDataCollectionEnabled
automaticDataCollectionEnabled: boolean;- The settable config flag for GDPR opt-in/opt-out 
property name
readonly name: string;- The (read-only) name for this app. - The default app's name is - "[DEFAULT]".- Example 1// The default app's name is "[DEFAULT]"const app = initializeApp(defaultAppConfig);console.log(app.name); // "[DEFAULT]"- Example 2// A named app's name is what you provide to initializeApp()const otherApp = initializeApp(otherAppConfig, "other");console.log(otherApp.name); // "other"
property options
readonly options: FirebaseOptions;- The (read-only) configuration options for this app. These are the original parameters given in initializeApp(). - Example 1const app = initializeApp(config);console.log(app.options.databaseURL === config.databaseURL); // true
interface FirebaseAppSettings
interface FirebaseAppSettings {}- Configuration options given to initializeApp() - Modifiers- @public
 
property automaticDataCollectionEnabled
automaticDataCollectionEnabled?: boolean;- The settable config flag for GDPR opt-in/opt-out. Defaults to true. 
property name
name?: string;- custom name for the Firebase App. The default value is - "[DEFAULT]".
interface FirebaseOptions
interface FirebaseOptions {}- Firebase 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. - Modifiers- @public
 
property apiKey
apiKey?: string;- An encrypted string used when calling certain APIs that don't need to access private user data (example value: - AIzaSyDOCAbC123dEf456GhI789jKl012-MnO).
property appId
appId?: string;- Unique identifier for the app. 
property authDomain
authDomain?: string;- Auth domain for the project ID. 
property databaseURL
databaseURL?: string;- Default Realtime Database URL. 
property measurementId
measurementId?: string;- An ID automatically created when you enable Analytics in your Firebase project and register a web app. In versions 7.20.0 and higher, this parameter is optional. 
property messagingSenderId
messagingSenderId?: string;- Unique numerical value used to identify each sender that can send Firebase Cloud Messaging messages to client apps. 
property projectId
projectId?: string;- The unique identifier for the project across all of Firebase and Google Cloud. 
property storageBucket
storageBucket?: string;- The default Cloud Storage bucket name. 
interface FirebaseServerApp
interface FirebaseServerApp extends FirebaseApp {}- A @firebase/app#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. - Modifiers- @public
 
property name
name: string;- There is no - getApp()operation for- FirebaseServerApp, so the name is not relevant for applications. However, it may be used internally, and is declared here so that- FirebaseServerAppconforms to the- FirebaseAppinterface.
property settings
readonly settings: FirebaseServerAppSettings;- The (read-only) configuration settings for this server app. These are the original parameters given in initializeServerApp(). - Example 1const app = initializeServerApp(settings);console.log(app.settings.authIdToken === options.authIdToken); // true
interface FirebaseServerAppSettings
interface FirebaseServerAppSettings extends Omit<FirebaseAppSettings, 'name'> {}- Configuration options given to initializeServerApp() - Modifiers- @public
 
property appCheckToken
appCheckToken?: string;- An optional App Check token. If provided, the Firebase SDKs that use App Check will utilize this App Check token in place of requiring an instance of App Check to be initialized. - If the token fails local verification due to expiration or parsing errors, then a console error is logged at the time of initialization of the - FirebaseServerAppinstance.
property authIdToken
authIdToken?: string;- An optional Auth ID token used to resume a signed in user session from a client runtime environment. - Invoking - getAuthwith a- FirebaseServerAppconfigured with a validated- authIdTokencauses an automatic attempt to sign in the user that the- authIdTokenrepresents. The token needs to have been recently minted for this operation to succeed.- If the token fails local verification due to expiration or parsing errors, then a console error is logged at the time of initialization of the - FirebaseServerAppinstance.- If the Auth service has failed to validate the token when the Auth SDK is initialized, then an warning is logged to the console and the Auth SDK will not sign in a user on initialization. - If a user is successfully signed in, then the Auth instance's - onAuthStateChangedcallback is invoked with the- Userobject as per standard Auth flows. However,- Userobjects created via an- authIdTokendo not have a refresh token. Attempted- refreshTokenoperations fail.
property releaseOnDeref
releaseOnDeref?: object;- An optional object. If provided, the Firebase SDK uses a - FinalizationRegistryobject to monitor the garbage collection status of the provided object. The Firebase SDK releases its reference on the- FirebaseServerAppinstance when the provided- releaseOnDerefobject is garbage collected.- You can use this field to reduce memory management overhead for your application. If provided, an app running in a SSR pass does not need to perform - FirebaseServerAppcleanup, so long as the reference object is deleted (by falling out of SSR scope, for instance.)- If an object is not provided then the application must clean up the - FirebaseServerAppinstance by invoking- deleteApp.- If the application provides an object in this parameter, but the application is executed in a JavaScript engine that predates the support of - FinalizationRegistry(introduced in node v14.6.0, for instance), then an error is thrown at- FirebaseServerAppinitialization.
Package Files (1)
Dependencies (5)
Dev Dependencies (6)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@firebase/app.
- Markdown[](https://www.jsdocs.io/package/@firebase/app)
- HTML<a href="https://www.jsdocs.io/package/@firebase/app"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
 Package analyzed in 3590 ms.
- Missing or incorrect documentation? Open an issue for this package.
