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/auth > initializeAuth

initializeAuth() function

Initializes an Auth instance with fine-grained control over Dependencies.

Signature:

export declare function initializeAuth(app: FirebaseApp, deps?: Dependencies): Auth;

Parameters

Parameter Type Description
app FirebaseApp
deps Dependencies

Returns:

Auth

Description

This function allows more control over the Auth instance than getAuth(). getAuth uses platform-specific defaults to supply the Dependencies. In general, getAuth is the easiest way to initialize Auth and works for most use cases. Use initializeAuth if you need control over which persistence layer is used, or to minimize bundle size if you're not using either signInWithPopup or signInWithRedirect.

For example, if your app only uses anonymous accounts and you only want accounts saved for the current session, initialize Auth with:

const auth = initializeAuth(app, {
  persistence: browserSessionPersistence,
  popupRedirectResolver: undefined,
});