Providers
and Events
, developers can implement or override specific aspects of the authentication flow, tailoring the user experience to meet the unique needs of their applications.
- Providers: These manage critical components such as session handling and authentication mechanisms, including traditional password-based sign-ins. They allow developers to define how users are authenticated, how sessions are maintained, and how accounts are managed within the application.
- Events: These handle specific actions and responses within the authentication flow. They allow developers to customize behaviors when certain events occur, such as when the authentication process finishes, when an error is encountered, or when the flow detects a new user and prompts for registration.
All Events and Provider handlers are optional!
Providers
Session
The Session Provider is responsible for creating and managing user sessions. In this implementation, use thecreate
method to create a user session utilizing the data.token
returned from your backend, and return a status indicating whether the session creation was successful or not.
Authentication
Use Authentication to implement your own password login handler

authenticate
method validates the user’s credentials, and the reset
method handles password reset requests.
authenticate
: This method attempts to log in the user using the provided loginId and password. If successful, it returns status: ‘logged-in’. If authentication fails, it returns status: ‘fail’ with a reason such as “Please enter a valid password.”reset
: This method handles the reset of user passwords. In this example, it redirects the user to a specific URL where they can manage password recovery.
Events
onFinish
TheonFinish
event is triggered when the authentication flow is successfully completed. This event allows you to define actions that should be taken once the user is authenticated, such as redirecting the user to a specific page.
onAccountNotFound
Use
onAccountNotFound
to use your own registration flowsonAccountNotFound
event is triggered when the provided account details do not match any existing accounts. This event allows you to handle scenarios where a user needs to be registered or redirected to a registration page.
onClose
TheonClose
event is triggered when the authentication flow is closed, either by user action or automatically. This event allows developers to define what should happen when the authentication flow is interrupted or completed without a successful login.
onError
TheonError
event is triggered when an error occurs during the authentication flow. This event allows developers to handle errors gracefully, such as by logging them or displaying error messages to the user.
Complete Code Example
Next Step
UI Customizations
Click here to move to the next step ->