Skip to content

A production‑ready monorepo starter kit built with Next.js, NestJS, and Auth.js, featuring JWT‑based authentication, full RBAC (Role‑Based Access Control), and a scalable architecture suitable for SaaS, enterprise, and multi‑tenant applications.

License

Notifications You must be signed in to change notification settings

Deveripon/next-nest-auth-js-starterkit

Repository files navigation

🚀 Monorepo Full‑Stack Starter Kit

A production‑ready monorepo starter kit built with Next.js, NestJS, and Auth.js, featuring JWT‑based authentication, full RBAC (Role‑Based Access Control), and a scalable architecture suitable for SaaS, enterprise, and multi‑tenant applications.

This starter kit is designed to help you move fast while following best practices for security, code sharing, and maintainability.


✨ Features

🧩 Monorepo Architecture

  • Single repository for frontend, backend, and shared packages
  • Shared types, auth config, and utilities
  • Consistent tooling and dependencies

🌐 Frontend (Next.js)

  • App Router support
  • Server Components + Client Components
  • Protected routes (RBAC aware)
  • Session handling via Auth.js
  • API-safe JWT handling

🧠 Backend (NestJS)

  • Modular architecture
  • JWT authentication guard
  • Role & permission guards
  • Custom decorators (@Roles(), @Permissions())
  • Fully protected REST APIs

🔐 Authentication & Authorization

  • Auth.js for authentication

  • JWT‑based auth (stateless & scalable)

  • Access & refresh token support

  • Full RBAC implementation

    • Roles (e.g. ADMIN, USER, EDITOR)
    • Fine‑grained permissions
  • Secure token verification on backend

📦 Shared Packages

  • Shared auth config
  • Shared types & utilities
  • ESM‑compatible packages

🧪 Developer Experience

  • Type‑safe end‑to‑end
  • ESLint + Prettier
  • Environment‑based config
  • Easy local development

🏗️ Project Structure

.
├── apps/
│   ├── frontend/            # Next.js frontend
│   └── backend/             # NestJS backend
│   └── docs/                # Fuma Docs
│
├── packages/
│   └── config/              # ESLint, TS configs
│
├── .env.example
├── package.json
├── pnpm-workspace.yaml
└── README.md

🔐 Authentication Flow

  1. User signs in via Next.js (Auth.js)
  2. Auth.js issues a JWT
  3. JWT is sent to NestJS via Authorization: Bearer <token>
  4. NestJS verifies token
  5. RBAC guards validate role & permissions
  6. Request is allowed or rejected

🔒 Protecting Frontend Routes (Next.js)

  • Middleware‑based route protection
  • Server‑side session validation

🚀 Getting Started

1️⃣ Install Dependencies

pnpm install

2️⃣ Run Development Servers

pnpm dev
  • Frontend: http://localhost:3000
  • Backend: http://localhost:5000

🧪 Scripts

Command Description
pnpm dev Run all apps in dev mode
pnpm build Build all packages
pnpm lint Lint entire repo
pnpm typecheck Type check all apps

📦 Deployment Notes

  • Frontend deployable on Vercel
  • Backend deployable on Docker / VPS / AWS / Fly.io
  • JWT makes backend fully stateless
  • Monorepo supports CI/CD easily

🧠 Why This Starter Kit?

✅ Production‑grade auth ✅ Clean RBAC implementation ✅ Scalable monorepo structure ✅ Perfect for SaaS & enterprise apps ✅ Saves weeks of setup time


📜 License

MIT License


🤝 Contributing

Contributions are welcome! Please open an issue or submit a PR.


⭐ Support

If you find this project useful, please give it a ⭐ on GitHub.

Happy coding! 🚀

About

A production‑ready monorepo starter kit built with Next.js, NestJS, and Auth.js, featuring JWT‑based authentication, full RBAC (Role‑Based Access Control), and a scalable architecture suitable for SaaS, enterprise, and multi‑tenant applications.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published