Before installation, set .env with your Keycloak data
NEXT_PUBLIC_KEYCLOAK_URL=http://localhost:8080
NEXT_PUBLIC_KEYCLOAK_REALM=your_realm
NEXT_PUBLIC_KEYCLOAK_CLIENT_ID=your_client_id
This project demonstrates a simple yet effective integration of Keycloak authentication within a Next.js (version 14) application.
- Keycloak Integration: Utilizes Keycloak for robust authentication and authorization.
- React Hooks: Implements React hooks for state management and side effects.
- Dynamic User Profiles: Dynamically loads and displays user profiles post-authentication.
- Secure Routing: Ensures that pages are only accessible to authenticated users.
Before you begin, ensure you have the following installed:
Follow these steps to get your Next.js app running with Keycloak authentication:
git clone https://github.com/csabika98/NextJS-Keycloak-JS.git
cd NextJS-Keycloak-JS
npm install
Set .env with your Keycloak data
npm run dev
Navigate to http://localhost:3000
to see your application in action. You will be redirected to the Keycloak login page if not authenticated.