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 > setPersistence

setPersistence() function

Changes the type of persistence on the Auth instance for the currently saved Auth session and applies this type of persistence for future sign-in requests, including sign-in with redirect requests.

Signature:

export declare function setPersistence(auth: Auth, persistence: Persistence): Promise<void>;

Parameters

Parameter Type Description
auth Auth The Auth instance.
persistence Persistence The Persistence to use.

Returns:

Promise<void>

A promise that resolves once the persistence change has completed

Description

This makes it easy for a user signing in to specify whether their session should be remembered or not. It also makes it easier to never persist the Auth state for applications that are shared by other users or have sensitive data.

Example

setPersistence(auth, browserSessionPersistence);