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:
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,
});