This is an example application that shows how next-auth
is applied to a basic Next.js app with Keycloak.
Go to next-auth.js.org for more information and documentation on NextAuth.
git clone https://github.com/jonryser/next-auth-poc.git
cd next-auth-poc
yarn
Use the Keycloak Accelerator to get the Keycloak server setup.
Install the startup realm that is included with the Keycloak accelerator.
Once the Keycloak server is running and the startup ("NextAuth POC") realm is installed
- switch to the "NextAuth POC" realm
- go to Realm settings -> Email
- update the Connection & Authentication
values to working email settings
Copy the .env.local.example file in this directory to .env.local (which will be ignored by Git):
cp .env.local.example .env.local
Update the Keycloak env vars:
KEYCLOAK_AUTHORIZATION=http://localhost:8180/realms/NextAuth_POC/protocol/openid-connect/auth
KEYCLOAK_CLIENT_ID=next-auth-poc
# The client secret can be any value
KEYCLOAK_CLIENT_SECRET=5ghC0E06conPaarRPQGId7VonTWIsq0u
KEYCLOAK_ISSUER=http://localhost:8180/realms/NextAuth_POC
KEYCLOAK_WELLKNOWN=http://localhost:8180/realms/NextAuth_POC/.well-known/openid-configuration
To run your site locally, use:
yarn dev
To run it in production mode, use:
yarn build
yarn start
Follow the Deployment documentation or deploy the example instantly using Vercel
Built off the original next-auth-example repo at https://github.com/nextauthjs/next-auth-example.git