The Auth SDK for React enables you to authenticate users using React-specific features.
Getting Started
1. Install the SDK
Install the SDK with your preferred package manager.
2. Wrap Your App with the Provider
In order for your microapp to have access to auth features, it needs to be wrapped in the AuthProvider component:
For local development, we recommend using the sandbox feature on the AuthProvider component to return mocked users:
The sandbox prop should only be used for local development. Do not use it in
production.
3. Use the useAuth Hook
The useAuth hook returns all of the auth data and methods available to your microapp. It returns the following type:
4. Prompt the User to Log In
You can prompt the user to log in by calling the requestLogin method.
5. Get Notified when the Authenticated User Changes
You can get notified when the authenticated user changes passing a callback on Auth initialization
6. Example Usage
Here is an example of how you can use the useAuth hook in your microapp: