An example of how we can integrate JWT token authentication to any Next.js 13 app which uses app directory feature.
-
git clone https://github.com/mehmetpekcan/nextjs-13-jwt-auth-example.git
-
cd nextjs-13-jwt-auth-example
-
npm install
oryarn
-
Copy
.env.example
to.env
or.env.local
-
Generate a Random JWT Secret Key:
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
-
Add generated hash code to
NEXT_PUBLIC_JWT_SECRET_KEY
in.env
file -
npm run dev
oryarn dev
-
Go to login page and use
admin
for userName and password.