A minimal React SPA example showing how to add authentication with MonoCloud.
- MonoCloud authentication in a React SPA
- Authorization Code + PKCE sign-in, sign-up, and sign-out
- Handling the sign-in and sign-out callbacks automatically with
<MonoCloudAuthProvider> - Reading the signed-in user with the
useAuth()hook
Built with @monocloud/auth-react.
Before you begin, you’ll need:
- A MonoCloud account
- A Single Page App configured for React in the MonoCloud Dashboard
Open src/main.tsx and replace the placeholders with values from your MonoCloud application:
<MonoCloudAuthProvider
tenantDomain="https://<your-domain>"
clientId="<your-client-id>"
>
<App />
</MonoCloudAuthProvider>Configure these in your MonoCloud app:
- Callback URL →
http://localhost:5173 - Sign-out URL →
http://localhost:5173 - Cross-Origin URL →
http://localhost:5173
npm install
npm run devOpen http://localhost:5173
- Wrapping the app with
<MonoCloudAuthProvider> - Reading the authenticated user with
useAuth() - Sign-in, sign-up, and sign-out actions with the built-in components
This repo is a reference, not a framework.
- React Quickstart: https://www.monocloud.com/docs/quickstarts/react
- React SDK Docs: https://www.monocloud.com/docs/sdks/react
- API Reference: https://monocloud.github.io/auth-js
- Use GitHub Issues for bug reports and feature requests.
- For tenant or account-specific help, contact MonoCloud Support through your dashboard.
Do not report security issues publicly. Please follow the contact instructions at: https://www.monocloud.com/contact
Licensed under the MIT License. See the included LICENSE file.