A Next.js application with TypeScript demonstrating Keycloak authentication integration.
npm installOption A: Using Docker (Recommended - No Manual Download Required)
docker run -d \
-p 8080:8080 \
-e KEYCLOAK_ADMIN=admin \
-e KEYCLOAK_ADMIN_PASSWORD=admin \
quay.io/keycloak/keycloak:26.0.1 \
start-devDocker will automatically download the Keycloak image on first run. Make sure Docker is installed (get it from docker.com).
Option B: Manual Download (Alternative) Download and install Keycloak from keycloak.org
- Access Keycloak Admin Console at
http://localhost:8080 - Login with admin credentials (default: admin/admin)
- Go to Clients → Create client
- Set Client ID:
react-client - Set Client authentication: OFF (Public client)
- Add Valid redirect URIs:
http://localhost:3000/* - Add Web origins:
http://localhost:3000 - Add Valid post logout redirect URIs:
http://localhost:3000/* - Click Save
create a .env file manually with:
NEXT_PUBLIC_KEYCLOAK_URL=http://localhost:8080
NEXT_PUBLIC_KEYCLOAK_REALM=master
NEXT_PUBLIC_KEYCLOAK_CLIENT_ID=react-client
npm run devThe app will open at http://localhost:3000 and you can login with Keycloak.
The app uses environment variables for configuration (with defaults):
NEXT_PUBLIC_KEYCLOAK_URL- Keycloak server URL (default:http://localhost:8080)NEXT_PUBLIC_KEYCLOAK_REALM- Realm name (default:master)NEXT_PUBLIC_KEYCLOAK_CLIENT_ID- Client ID (default:react-client)
This project includes an AI-powered assistant to help you with Keycloak setup and troubleshooting. Click the 🤖 button in the bottom right corner to chat with the AI assistant.
The AI can help you with:
- Setting up Keycloak server with Docker
- Creating and configuring clients
- Troubleshooting 401 errors and CORS issues
- Understanding tokens and authentication flow
- Setting up realms, users, and roles
- Environment variables and configuration
For more detailed troubleshooting, see:
- KEYCLOAK_SETUP.md - Complete Keycloak setup guide
- TROUBLESHOOTING_401.md - 401 error fixes
- CHECKLIST.md - Pre-run checklist