Next.js — JWT auth example app

Photo by David Papillon on Unsplash

0. Project Structure

There will be two folders. One is server and the other is app. The server one will contain an Express app, while the other will contain the Nextjs app. Both will run on their own ports. App/Client on 3000, and Express/Api on 3001.

1. Server side

Lets first build the server side. Start first with a standard Express.js app. Create it in the server folder.

2. Client side

Create a Nextjs app like you would normally in the appfolder. Now make apages folder and add the following two:




Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store