A minimal Next.js App Router example showing how to add authentication with MonoCloud.
- MonoCloud authentication with Next.js App Router
- Middleware-based route protection
- Reading the signed-in user (server + client)
- Sign in and sign out flows
Built with @monocloud/auth-nextjs.
Before you begin, you’ll need:
- A MonoCloud account
- A Web Application configured for Next.js in the MonoCloud Dashboard
This repo includes a .env.local template. Replace the placeholders with values from your MonoCloud application:
MONOCLOUD_AUTH_TENANT_DOMAIN=https://<your-domain>
MONOCLOUD_AUTH_CLIENT_ID=<your-client-id>
MONOCLOUD_AUTH_CLIENT_SECRET=<your-client-secret>
MONOCLOUD_AUTH_SCOPES=openid profile email
MONOCLOUD_AUTH_APP_URL=http://localhost:3000
MONOCLOUD_AUTH_COOKIE_SECRET=<random-secret>
⚠️ Do not commit real secrets. This file is for local development only.
Configure these in your MonoCloud app:
- Callback URL →
http://localhost:3000/api/auth/callback - Sign-out URL →
http://localhost:3000
npm install
npm run devOpen http://localhost:3000
- App Router–compatible auth middleware
- Protected routes and pages
- Server + client access to the authenticated user
- Built-in sign-in and sign-out components
This repo is a reference, not a framework.
- Next.js SDK Docs: https://www.monocloud.dev/docs/sdks/nextjs
- 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.