A minimal JavaScript SPA example showing how to add authentication with MonoCloud.
- MonoCloud authentication in a vanilla JavaScript SPA (no framework)
- Authorization Code + PKCE sign-in and sign-out
- Handling the sign-in and sign-out callbacks
- Reading the signed-in user from the session
Built with @monocloud/auth-web-js.
Before you begin, you’ll need:
- A MonoCloud account
- A Single Page App configured for JavaScript in the MonoCloud Dashboard
Open src/main.ts and replace the placeholders with values from your MonoCloud application:
const options: MonoCloudWebJSClientOptions = {
tenantDomain: "https://<your-domain>",
clientId: "<your-client-id>",
appUrl: "http://localhost:5173",
callbackPath: "/callback",
signOutCallbackPath: "/signout",
};Configure these in your MonoCloud app:
- Callback URL →
http://localhost:5173/callback - Sign-out URL →
http://localhost:5173/signout - Cross-Origin URL →
http://localhost:5173
npm install
npm run devOpen http://localhost:5173
- Client initialization with
MonoCloudWebJSClient - Sign-in and sign-out callback handling
- Reading the authenticated user from the session
- Sign-in and sign-out actions
This repo is a reference, not a framework.
- JavaScript Quickstart: https://www.monocloud.com/docs/quickstarts/web-js
- JavaScript SDK Docs: https://www.monocloud.com/docs/sdks/web-js
- 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.