Skip to content

lauriskuznecovs/next-js-jwt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Next.js and Express JWT authentication

Introduction

This repo hold both - server and client apps for fully functional example of JWT authentication.

  • Server - based on Express and MongoDB as data storage, but can be replaced to any custom data storage.
  • Client - based on Next.js.

Workflow

  1. Run MongoDB, Server and Client.

  2. Register user (described in backend directory).

  3. Enter enter email/password in client app, press submit.

  4. App sends request to server for user authentication.

    • SUCCESS - responds with token which is stored in cookie.

    • FAILURE - respond with particular HTTP code (no user data specified or wrong auth data provided).

  5. By navigating between pages client app sends request to server with token to validation.