Prerequisites
- Created your Unkey account
- Created an API in the Unkey dashboard
Skip the tutorial
We also have a Next.js example ready to deploy on Vercel.
1
Create Next.js Application
Run the following command to init your Next.js project
2
Install
Now install the
@unkey/nextjs package3
Creating a protected route
Create a new route and add the following code
/app/protected/route.ts
4
Running it
5
Try it out
Go to https://app.unkey.com and create a new key. Then verify it with our new server:It should return
"Your API key is valid!" and log out {"keyId":"key_id","valid":true,"meta":{},"enabled":true,"permissions":[],"code":"VALID"} and potentially more information about the key, depending on what you set up in the dashboard.