Build a custom multi-session flow
A multi-session application is an application that allows multiple accounts to be signed in from the same browser at the same time. The user can switch from one account to another seamlessly. Each account is independent from the rest and has access to different resources.
This guide provides you with the necessary information to build a custom multi-session flow using Clerk's API.
To implement the multi-session feature to your application, you need to handle the following scenarios:
- Switching between different accounts
- Adding new accounts
- Signing out from one account, while remaining signed in to the rest
- Signing out from all accounts
Enable multi-session in your application
To enable multi-session in your application, you need to configure it in the Clerk Dashboard.
- Navigate to the Clerk Dashboard and select your application.
- In the navigation sidebar, select Sessions.
- Toggle on Multi-session handling.
- Select Save changes.
Get the active session and user
Add a new session
To add a new session, simply link to your existing sign-in flow. New sign-ins will automatically add to the list of available sessions on the client. To create a sign-in flow, please check one of the following popular guides:
For more information on how Clerk's sign-in flow works, check out the detailed sign-in guide.
Sign out all sessions
Use signOut()
to deactivate all sessions on the current client.
Sign out active session
Use signOut()
to deactivate a specific session by passing the session ID.
Feedback
Last updated on