Learn how to access and manage the user authentication state on the client-side in your Next.js application.
CorbadoProvider
has to be integrated.
Find more here.useCorbado()
hook.
It gives you access to the following state:
State | Type | Description |
---|---|---|
isAuthenticated | boolean | Indicates if the user is logged in. |
loading | boolean | If true, the SDK is still in a loading state. You should then not yet make use of the other states but wait until loading = false . |
sessionToken | string | undefined | A JWT that proves that the user is authenticated. It can be used to make calls to your backend and thus should be included as an authorization header in the requests to such a backend. A value of undefined indicates that the user is not logged in. |
user | SessionUser | undefined | An object that holds basic information about the user. A value of undefined indicates that the user is not logged in. |
Name | Description |
---|---|
getFullUser | Get the complete user object. In addition to the user state from above this gives you access to a user’s login identifiers. |
getPasskeys | Get all passkeys that are available for the current user. |
appendPasskey | Creates a new passkey for an already authenticated user. This only works if the user has not already set up another passkey for the same device. |
deletePasskey | Delete a passkey for the current user. |
logout | Logs the user out of your application and cleans all local authentication state. |
getPasskeys
, appendPasskey
and deletePasskey
to provide a passkey management interface.Only if you want to build your custom UI components there is a need to make use of these operations yourself.