@scute/react-hooks package. This package exposes the useAuth and useScuteClient hooks, which allow you to build your own custom UI while still leveraging Scute’s authentication logic.
Head over to the example projects repo to see the hooks in action and check out the type docs for more scuteClient methods.
To get started, install our React SDK with your favorite package manager:
Terminal
Initialize the Scute client
First initialize the Scute client using thecreateClient method exposed by @scute/react-hooks package:
Wrap your React app with Scute AuthContextProvider
To be able to use theuseScuteClient and useAuth hooks, wrap your app inside the Scute AuthContextProvider:
Using the hooks
Now you can use theuseAuth and useScuteClient hooks in your components.
useAuth
The useAuth hook provides access to the authentication state and the current user.
| Property | Type | Description |
|---|---|---|
session | Session | The current authentication session. |
user | ScuteUserData or null | The currently authenticated user, or null if not authenticated. |
signOut | () => Promise<void> | A function to sign the user out. |
useScuteClient
The useScuteClient hook provides access to the Scute client instance.
| Property | Type | Description |
|---|---|---|
scute | ScuteClient | The Scute client instance. |