Skip to content

Authentication monorepo with a Fastify API + Next.js frontend. Complete JWT control and shared Zod schemas — no magic libraries.

Notifications You must be signed in to change notification settings

risixdzn/authboilerplate

Repository files navigation

Authentication Boilerplate Monorepo

A starting point for custom authentication without magic libraries. This monorepo provides:

  • A Fastify API using JWT refresh tokens, accepting credentials via the Authorization header or a token cookie.
  • A Next.js 14 Frontend with server/client authentication, middleware revalidation, and Axios interceptors.
  • Shared Zod schemas via the @repo/schemas package.
  • Turborepo for local package sharing and scripting.

API

Built with Fastify, the API handles auth using:

Documentation is available on the following API routes:

  • Scalar UI for a modern interface at /docs
  • Swagger for the classic one at /reference

Frontend

The frontend leverages Next.js 14 for seamless server/client authentication, with revalidation in middleware and auth interceptors powered by Axios.

Authentication Flow

Users authenticate via JWT refresh tokens. Supported actions include:

  • Password reset (authenticated and "forgot password")
  • Email confirmation before signup
  • Account deletion
  • Display name updates

Authentication Flow

Development Setup

Begin by configuring your environment. Rename and update the provided .env.example files:

Next, spin up your Postgres and Redis databases with Docker Compose:

docker compose up

Install dependencies and run database migrations:

npm install
npm run migrate

Finally, start the development server:

npm run dev

About

Authentication monorepo with a Fastify API + Next.js frontend. Complete JWT control and shared Zod schemas — no magic libraries.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages