- Go to Clerk and create a new application or use an existing one.
- On your application dashboard to to
API Key - Use the
Quick Copyfor Next.js and copy the.env.local - Create a new
.env.localfile in the root folder (next to thepackage.json) - Paste the credentials into the
.env.localfile - Go to
JWT Templatesand create a newBlanktemplate - Name it
wundergraph - Use the following template: (You can also include other claims as needed)
{
"id": "{{user.id}}",
"email": "{{user.primary_email_address}}",
"lastName": "{{user.last_name}}",
"username": "{{user.username}}",
"firstName": "{{user.first_name}}"
}- Copy the JWKS Endpoint url
- Add a new environment variable to
.env.localcalledCLERK_JWKS_URLand paste the url as the value
- Install the dependencies and run the complete example in one command:
npm install && npm startOn the NextJS frontend, click the "Login" button. Once the login is complete, the Frontend will automatically fetch the data and inject the bearer token into the origin request.
Join us on Discord!