More Premium Hugo Themes Premium Nextjs Themes

Nextjs Jwt Auth Boilerplate

NextJS + ChakraUI + Prisma + JWT-based Authentication + Two-Factor Authentication + Sentry

Nextjs Jwt Auth Boilerplate

NextJS + ChakraUI + Prisma + JWT-based Authentication + Two-Factor Authentication + Sentry

Author Avatar Theme by lucadibello
Github Stars Github Stars: 114
Last Commit Last Commit: Oct 25, 2023 -
First Commit Created: Dec 18, 2023 -
Nextjs Jwt Auth Boilerplate screenshot

Overview:

This project is a NextJS JWT authentication boilerplate developed as an example of JWT token-based authentication in a web environment for a research project at the University of Applied Sciences of Southern Switzerland. It includes features such as Sentry error tracking, login with email and password, role-based access control, automatic JWT access token refresh, two-factor authentication via email, and protected routes and pages.

Features:

  • Sentry error tracking
  • Fully-typed with TypeScript
  • Login with email and password (hashed with bcrypt)
  • Role-based access control (User, Admin)
  • Automatic JWT access token refresh
  • Two-factor authentication via email
  • Front-end useAuth hook for user session management
  • User session persistence via cookies and local storage
  • New flexible back-end middleware management system

Installation:

To get started with this theme, you’ll need to follow these steps:

Prerequisites

  • Node.js v14.17.0 or higher
  • Yarn v1.22.10 or higher
  • PostgreSQL v13.3 or higher

Configuration

  1. Install the required packages.
  2. (Optional) Create a new PostgreSQL container with Docker.
  3. Copy the .env.example file to .env and fill in the required environment variables.
  4. Push the database schema and seed data to the database.
  5. Start the development server.

Summary:

This NextJS JWT authentication boilerplate provides a fully functional two-factor authentication system based on JWT tokens. It includes features such as error tracking using Sentry, login with email and password, role-based access control, automatic token refresh, two-factor authentication via email, and protected routes and pages. The installation process requires Node.js, Yarn, and PostgreSQL, and involves installing packages, configuring environment variables, and setting up the database.