voluptasmollitia
Version:
Monorepo for the Firebase JavaScript SDK
40 lines (24 loc) • 1.46 kB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@firebase/auth](./auth.md) > [initializeAuth](./auth.initializeauth.md)
## initializeAuth() function
Initializes an Auth instance with fine-grained control over [Dependencies](./auth.dependencies.md)<!-- -->.
<b>Signature:</b>
```typescript
export declare function initializeAuth(app: FirebaseApp, deps?: Dependencies): Auth;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| app | [FirebaseApp](./app.firebaseapp.md) | |
| deps | [Dependencies](./auth.dependencies.md) | |
<b>Returns:</b>
[Auth](./auth.auth.md)
## Remarks
This function allows more control over the Auth instance than [getAuth()](./auth.getauth.md)<!-- -->. `getAuth` uses platform-specific defaults to supply the [Dependencies](./auth.dependencies.md)<!-- -->. 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:
```js
const auth = initializeAuth(app, {
persistence: browserSessionPersistence,
popupRedirectResolver: undefined,
});
```