This repository demonstrates how to use Keycloak as an authentication broker for a Next.js v13 application.
npm run demo
This will automatically:
- Clean up any existing environment
- Remove previous Docker containers and tunnels
- Set up fresh environment variables
- Start Docker containers (Keycloak + Postgres)
- Create secure tunnels for external access
- Configure Keycloak
- Launch the Next.js application
- Node.js 16 or higher
- Docker and Docker Compose
- Cloudflared
- macOS users with Homebrew:
brew install cloudflared
- Other platforms: Installation Guide
- macOS users with Homebrew:
For detailed setup instructions, see:
- Demo Guide - Quick start and basic setup
- Keycloak Setup - Detailed Keycloak configuration
- Walkthrough - Step-by-step feature exploration
# Start in development mode
npm run dev
# Build for production
npm run build
# Start in production mode
npm start
Note: For local development without tunnels, set appropriate environment variables in
.env.local
For a detailed explanation, check out our blog post
docker compose up -d
Please note that the above method cannot be used for production.
NODE_OPTIONS='--dns-result-order=ipv4first' npm run dev
npm run build
Open http://localhost:3000 with your browser to see the result.
NODE_OPTIONS='--dns-result-order=ipv4first' npm start
Make sure to setup the environment variables.