Skip to main content
For applications that need declarative routing with protected routes, you can combine Scute’s React hooks with React Router. This approach provides a clean separation of concerns where each authentication step is handled as a separate route, and protected routes automatically redirect unauthenticated users. Head over to the example projects repo to see the React Router implementation in action and check out the type docs for more scuteClient methods. To get started, install our React SDK and React Router with your favorite package manager:
Terminal
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-hooks package:

Wrap your React app with providers and router

Set up your app with both the Scute provider and React Router:

Set up your routes

Define your routes declaratively with React Router:

Create route components

Each authentication step becomes its own component. Here’s an example login component:
And a protected profile component:

Route navigation patterns

Use React Router’s navigation hooks to move between authentication steps: