React
Using the pre-built Scute UI with React
If you would like to use the pre-built Scute UI with your react app, you can do so using the @scute/ui-react package. This package would expose the pre-built Auth and Profile components which you can use to easily integrate Scute to your current app.
Head over to the example project repo to clone and run this example project and check out the type docs for more scuteClient methods.
To get started, install our React SDKs with your favorite package manager:
Add your credentials to your environment variable handler:
NOTE: If you are not using Vite, use "REACT_APP" as your prefix for your environment variables.
Initialize the Scute client
First initialize the Scute client using the createClient method exposed by @scute/react package:
Wrap your React app with Scute AuthContextProvider
To be able to use the useScuteClient and useAuth hooks, wrap your app inside the Scute AuthContextProvider:
Add the Scute pre-built UI
First, create a component to show to your authenticated users:
Then, create a component to switch between the authentication form and the AuthenticatedView based on the session status:
Finally, modify the App.jsx to render the ScuteUI inside the AuthContextProvider:
Congrats! You have a working Scute instance now!
No session
With session (Profile)
With session (UserButton)
Component API's
Auth Component
| Property | Type | Default | Description |
|---|---|---|---|
| scuteClient | ScuteClient | undefined | The Scute client instance. This property is required |
| onSignIn? | () => void | undefined | Callback function for sign-in |
| webauthn? | "strict" | "optional" | "disabled" | "optional" | Options for WebAuthn |
| language? | string | "en" | Language setting |
| appearance? | ? | undefined | Appearance settings |
Profile Component
| Property | Type | Default | Description |
|---|---|---|---|
| scuteClient | ScuteClient | undefined | The Scute client instance |
| language? | string | "en" | Language setting |
UserButton Component
| Property | Type | Default | Description |
|---|---|---|---|
| scuteClient | ScuteClient | undefined | The Scute client instance |
| language? | string | "en" | Language setting |
| username? | string | undefined | Username to display |
| profileUrl? | string | undefined | Profile URL to navigate to |
| profilePictureUrl? | string | undefined | Profile picture URL |
Last updated on