Configuring the client
Every option createAuth takes, with a page for each part of the client you can configure.
The client from Getting started sets a few
options and leaves the rest to their defaults. When your app outgrows them,
because your backend sends tokens differently, sessions must last longer, or
you need to see why a user was signed out, the options passed to
createAuth are where you change it.
This page lists every option, and the pages in this section explain each part of the client in turn.
Options
createAuth takes three required options and five optional ones:
| Option | Required | What it sets |
|---|---|---|
name | Yes | Names the saved session and the refresh lock: letters, digits, _ or -, up to 64 characters. Keeps two apps on one origin apart. |
user | Yes | A user schema, or fromAccessToken. |
storage | Yes | Where the session is saved. |
refresh | No | How to get new tokens. Without it, the user is signed out when the access token expires or your API rejects it. |
revoke | No | Revokes the ended tokens on your backend after a sign-out. |
maxAge | No | How long a saved session lasts, in seconds. Default: 30 days, counted from each save. |
debug | No | Reports what the client does. Default: off. |
locking | No | Restores a saved session as locked, for native apps. Default: off. |
createAuth throws an AuthError with the code INVALID_OPTIONS when it
can't use an option, such as a name with other characters, or a maxAge
that isn't a positive whole number.
Pages in this section
Each page covers one part of the client: how it checks users, gets new tokens, saves the session, follows other tabs, and reports what happens.
- User schemasWhen the schema checks users, and what restoring a session asks of it.
- RefreshWhat the refresh callback returns, when a refresh runs, and what happens when it fails.
- ExpiryHow the client finds out when the access token expires.
- StorageWhere the session is saved, how long it lasts, and how to write your own store.
- TabsHow tabs follow each other's sign-ins, and take turns to refresh.
- ErrorsWhere errors appear, how to show them, and the failures that need a decision from you.
- DebuggingLog what the client does, or send it to your error reporting.