Skip to content

JWT Authentication

Learn how to do JWT authentication at the edge.

Framework Next.js
Use Case Edge Functions
CSS Tailwind
Publisher ▲ Vercel

JWT Authentication

The example shows how to do JWT authentication at the edge.

Demo

https://edge-functions-jwt-authentication.vercel.app

How to Use

You can choose from one of the following two methods to use this repository:

One-Click Deploy

After setting up your JWT secret, deploy the example using Vercel:

Clone and Deploy

Execute create-next-app with npm or Yarn to bootstrap the example:

npx create-next-app --example https://github.com/vercel/examples/tree/main/edge-functions/jwt-authentication
# or
yarn create next-app --example https://github.com/vercel/examples/tree/main/edge-functions/jwt-authentication
Set up environment variables

Rename .env.example to .env.local:

cp .env.example .env.local

then, update JWT_SECRET_KEY with your a random secret that'll be used to sign JWTs.

Next, run Next.js in development mode:

npm install
npm run dev

# or

yarn
yarn dev

Deploy it to the cloud with Vercel (Documentation).

JWT Authentication

Learn how to do JWT authentication at the edge.

Framework Next.js
Use Case Edge Functions
CSS Tailwind
Publisher ▲ Vercel

JWT Authentication

The example shows how to do JWT authentication at the edge.

Demo

https://edge-functions-jwt-authentication.vercel.app

How to Use

You can choose from one of the following two methods to use this repository:

One-Click Deploy

After setting up your JWT secret, deploy the example using Vercel:

Clone and Deploy

Execute create-next-app with npm or Yarn to bootstrap the example:

npx create-next-app --example https://github.com/vercel/examples/tree/main/edge-functions/jwt-authentication
# or
yarn create next-app --example https://github.com/vercel/examples/tree/main/edge-functions/jwt-authentication
Set up environment variables

Rename .env.example to .env.local:

cp .env.example .env.local

then, update JWT_SECRET_KEY with your a random secret that'll be used to sign JWTs.

Next, run Next.js in development mode:

npm install
npm run dev

# or

yarn
yarn dev

Deploy it to the cloud with Vercel (Documentation).

Unleash New Possibilities

Deploy your app on Vercel and unlock its full potential