This guide will show you how to use Clerk as your authentication provider in an existing Next.js + WunderGraph application.
- Go to Clerk and create a new application or use an existing one.
- On your application dashboard to to
- Use the
Quick Copyfor Next.js and copy the
- Create a new
.env.localfile in the root folder (next to the
- Paste the credentials into the
- Go to
JWT Templatesand create a new
- Name it
- Use the following template: (You can also include other claims as needed)
- Copy the JWKS Endpoint url
wundergraph.config.ts and add a new token-based authentication provider:
pages/_app.tsx and add the
useWunderGraphClerk middleware to the
That's it! Your WunderGraph application is now protected by Clerk.