React Next.js 16.4 SaaS Starter with Auth - Next Elite
A Next.js 16.4 starter kit with Tailwind CSS, TypeScript, and built‑in authentication and dashboard layouts for SaaS applications.
By salmanshahriar salmanshahriar/next-elite 134 stars
Introduction
Next Elite is an open‑source starter kit for building SaaS and admin dashboard applications with Next.js 16.4, React 19, TypeScript 7 and Tailwind CSS 4. It includes ready‑made authentication, role‑based access control, dark mode, internationalisation and a collection of reusable UI components.
What this project offers
- A complete Next.js app router structure with separate routes for public, authentication and protected pages.
- Built‑in authentication using better‑auth (email/password and Google OAuth).
- Role‑based access control (RBAC) for user and admin roles.
- Type‑safe internationalisation powered by next‑intl with six locales.
- Dark mode support that follows the system preference.
- Over 50 custom UI components based on shadcn/ui, Radix UI and Tailwind CSS.
- Server‑side error tracking with Sentry.
- Dockerfile for containerised deployment.
- Testing setup with Vitest (unit) and Playwright (end‑to‑end).
Main features
| Feature | Description |
|---|---|
| Auth Layouts | Split‑pane login/register pages with lazy‑loaded background. |
| Dashboard Layouts | Sidebar navigation, top bar, and role‑based content slots. |
| Type‑safe i18n | Compile‑time checked translation keys, cookie‑based locale selection. |
| Dark Mode | System‑default theme with toggle and reduced‑motion support. |
| RBAC | Simple permission checks via useAuth().hasPermission(). |
| Custom UI Components | Accessible primitives built with Tailwind CSS 4, Radix UI and CVA. |
| Server Actions | Ready for Next.js server actions in the app router. |
| Docker support | Multi‑arch Dockerfile included. |
| Testing | Vitest unit tests and Playwright E2E tests configured. |
Technology stack
- Framework: Next.js 16.4 (App Router)
- UI: React 19, Tailwind CSS 4, shadcn/ui, Radix UI
- Language: TypeScript 7
- Styling: PostCSS 8, Tailwind CSS 4
- State & Data: @tanstack/react‑query
- Authentication: better‑auth
- Internationalisation: next‑intl
- Observability: @sentry/nextjs
- Testing: Vitest, Playwright
- Containerisation: Docker
Requirements
- Node.js >= 22.18.0 (as defined in
package.jsonengines field)
Installation
- Download the project
curl -L -o next-elite.zip /download/next-elite.zip
unzip next-elite.zip -d next-elite
cd next-elite
- Install dependencies
npm ci
- Build the application (required before running)
npm run build
The build creates a .next folder. The production server files are in .next/standalone and the static assets are in .next/static.
- Start the development server (optional, for local testing)
npm run dev
The app will be available at http://localhost:6767.
- Run the production server (after a successful build)
npm run start
Or use the standalone build:
npm run start:standalone
Configuration
- Environment variables are defined in
.env.example. Copy it to.env.localand adjust values such as database URLs, OAuth client IDs, and Sentry DSN. - Docker configuration is provided in
Dockerfileanddocker-compose.yml. Build the image withdocker compose buildand run withdocker compose up. - Linting and formatting are set up with oxlint and oxfmt; they run automatically via a Lefthook pre‑commit hook (
npm run prepare).
Customizing the project
- UI components live in
src/components/uiand can be extended or replaced. - Tailwind configuration is in
tailwind.config.cjs(generated by the Tailwind package). Adjust colors, spacing, or add plugins there. - Internationalisation files are under
src/messages(e.g.,en.json,fr.json). Add new locale files and updatenext-intlconfiguration insrc/app/i18n.ts. - Authentication logic is in
src/app/(auth)and the API routesrc/app/api/auth. Modify the BetterAuth options to integrate your own user store.
Project structure
/
├─ Dockerfile
├─ docker-compose.yml
├─ next.config.ts
├─ package.json
├─ postcss.config.mjs
├─ public/ # static assets (images, icons)
├─ scripts/ # helper scripts (bundle size, demo removal)
├─ src/
│ ├─ app/ # Next.js app router (auth, protected, public)
│ ├─ components/ # UI components (auth, layout, shared, ui)
│ ├─ features/ # feature modules (auth, i18n, site)
│ ├─ hooks/ # custom React hooks
│ ├─ libs/ # utility libraries (env, query client)
│ └─ tests/ # Vitest and Playwright tests
└─ tsconfig.json
Tips
- Run
npm run typecheckto verify TypeScript types without emitting files. - Use
npm run lintandnpm run lint:fixto keep code style consistent. - To see bundle size, execute
npm run size. - For fast feedback, run Vitest in watch mode:
npm run test:watch. - Playwright browsers can be installed separately with
npm run playwright:install.
License and attribution
The project is licensed under the MIT License. See the LICENSE file in the repository.
Original repository: https://github.com/salmanshahriar/next-elite
When redistributing, keep the license file and credit the author as required by the MIT license.
Use this prompt with an AI coding assistant (Claude Code, Cursor, Copilot, ChatGPT and similar).
- Download the ZIP and extract it where your new project will live.
- Download the ZIP and extract it next to your project, so the assistant can read both.
- Fill in the bracketed parts under “About my project”.
- Paste the prompt into your assistant and review each change it proposes.
# Start a new project with Next Elite ## Your task You are a senior frontend engineer. We are building a new project using Next Elite, a starter template built with Tailwind CSS 4, as the starting point. Keep its design and turn the demo into a clean, real codebase that I can maintain. ## About my project - What I'm building and for whom: [describe it] - Pages I need: [list them] - Stack: [keep it as it is, with its own build, or name one: Vite / Laravel / Next.js / Astro] - Brand: [name, colours, fonts, logo] # Next Elite — project brief ## Source project Next Elite is a starter kit for SaaS and admin dashboards built with Next.js 16.4 and Tailwind CSS v4. It includes TypeScript, authentication, dashboard layouts, i18n and dark‑mode support. Repository: https://github.com/salmanshahriar/next-elite, license MIT (see LICENSE, author credited in README). ## Files that matter **Pages (entry points)** - `src/app/(public)/layout.tsx` – root layout, loads global CSS and providers, entry point for public routes. - `src/app/(auth)/layout.tsx` – layout for authentication pages (login, register). - `src/app/(protected)/layout.tsx` – layout for protected dashboard pages, includes sidebar and top‑bar. - `src/app/(public)/page.tsx` – home page shown to unauthenticated visitors. - `src/app/(auth)/login/page.tsx`, `src/app/(auth)/register/page.tsx` – auth pages. - `src/app/(protected)/dashboard/page.tsx` – example dashboard page. **Stylesheets** - `src/app/globals.css` – Tailwind base, components and utilities. - `src/app/styles/tokens.css` – design tokens (colors, radius, spacing) used by dark mode. - `src/app/styles/*.css` – any additional component‑specific CSS. **Scripts** - `scripts/check-bundle-size.ts` – bundle‑size check used by `npm run size`. - `scripts/remove-demo.ts` – removes demo content (`npm run demo:remove`). **Images & fonts** - `public/Next-Elite-Home.webp`, `public/Next-Elite-Auth.webp`, `public/Next-Elite-Admin.webp`, `public/Next-Elite-LightHouse.webp`, `public/Next-Elite-OG.webp`, `public/Nextjs-Elite-UI-Components.webp` – demo screenshots used in README. - `public/favicon.ico`, `public/icon.svg`, `public/logo.svg` – site icons. **Configuration** - `next.config.ts` – Next.js configuration (app router, image domains, etc.). - `postcss.config.mjs` – PostCSS with Tailwind v4. - `tailwind.config.cjs` (implicitly present via devDependency). - `tsconfig.json` – TypeScript compiler options. - `config/vitest.config.ts`, `config/vitest.setup.ts` – Vitest testing configuration. - `config/playwright.config.ts` – Playwright E2E configuration. - `lefthook.yml` – Git hook configuration. **Entry page** - The root layout `src/app/(public)/layout.tsx` together with `src/app/(public)/page.tsx` forms the entry point for the site. ## Setup and build The project requires a build step. ```bash # Install dependencies npm ci # Development server (http://localhost:6767) npm run dev # Production build npm run build # Start the built app npm run start ``` The production build outputs to the default `.next` directory; `npm run start:standalone` can run the standalone server from `.next/standalone`. ## How it is put together - **Layout structure**: Three parallel route groups – `(public)`, `(auth)`, and `(protected)` – each with its own `layout.tsx`. The protected layout contains a fixed sidebar navigation, a top bar, and a content outlet. The auth layout shows a split‑pane with an animated globe background (lazy‑loaded). - **Reusable UI**: Components live under `src/components/` (e.g., `auth/`, `layout/`, `shared/`, `ui/`). Most UI primitives are built with **shadcn/ui**, **Radix UI** and styled via Tailwind utility classes. - **State & data**: `src/libs/query-client.ts` creates a TanStack Query client; `src/components/shared/query-provider.tsx` wraps protected routes. Authentication is handled by **better-auth** (`/api/auth/*`). - **Theme & dark mode**: Tokens in `src/app/styles/tokens.css` define light and dark color palettes. The `use-is-dark-theme.ts` hook reads system preference and stores the choice; `color-scheme` meta tag and Tailwind’s `dark:` variant apply the theme. - **Internationalization**: `next-intl` provides type‑safe i18n; locale files are in `messages/` (e.g., `en.json`, `fr.json`). The `src/app/providers.tsx` sets up the `NextIntlProvider`. - **Additional libraries**: Radix UI components (accordion, dropdown, tooltip, etc.), Phosphor icons, React Hook Form, React Day Picker, Embla carousel, Cobe (3‑D globe), and Sentry for error tracking. - **Build optimisation**: Tailwind v4 purge, per‑page JS budgets, and lazy loading of heavy components (charts, globe) keep the initial bundle ~184 KB Brotli. ## Watch out for 1. **Tailwind version** – The project uses Tailwind v4; class names and configuration differ from v3 (e.g., `container` defaults, new `@layer` syntax). 2. **Global CSS** – `globals.css` imports Tailwind base styles that reset many native element styles; custom component CSS must respect this reset. 3. **CDN‑loaded assets** – The animated globe (`cobe`) is lazy‑loaded only on desktop; ensure the client environment supports dynamic `import()`. 4. **DOM expectations** – Sidebar navigation assumes the presence of elements with IDs `sidebar` and `topbar`; removing or renaming them breaks the layout toggles. 5. **Duplicate library imports** – Both `@radix-ui/react-dropdown-menu` and `@radix-ui/react-menu` could be imported inadvertently; keep imports consistent to avoid bundle bloat. 6. **Dark‑mode tokens** – Colors are defined in `tokens.css`; overriding them in component CSS without using the token variables may cause mismatched light/dark themes. ## Verify - [ ] Home page (`/`) renders with the public layout and displays the hero section. - [ ] Auth pages (`/login`, `/register`) load the split‑pane layout and the globe component without console errors. - [ ] Protected dashboard page renders the sidebar, top bar, and a sample widget after authentication. - [ ] Dark‑mode toggle changes colors according to tokens in `tokens.css` and updates the `color-scheme` meta tag. - [ ] Internationalization works for at least two locales (e.g., `en` and `fr`) and page titles change accordingly. - [ ] No duplicate loading of Tailwind or Radix CSS; inspect the built HTML for a single `` to the compiled CSS. - [ ] `npm run build` completes without TypeScript errors (`npm run typecheck`) and the production server starts with `npm run start`. - [ ] Sentry initialization does not throw errors when the environment variable `NEXT_PUBLIC_SENTRY_DSN` is missing (fallback to no‑op). # How to work ## Step 1 — Get it running as it is Start from the downloaded ZIP or a clone of the repository. Install the dependencies and start the dev server with the exact commands in "Setup and build" above. Confirm it runs without console errors before changing anything. ## Step 2 — Plan the project with me List the pages and sections of Next Elite to keep, rename or remove for my project, the folder structure you propose for my stack, and where the repeated parts will live. Wait for my OK. ## Step 3 — Build it - Keep the pages I need, remove the rest, and replace the sample content with real content. - Extract repeated parts (header, navigation, footer) into shared partials or components. - Put my brand name, colours and fonts where Next Elite defines its theme (see "How it is put together" above), not as one-off overrides. - Keep Tailwind CSS's markup patterns and class conventions so the design stays consistent, and don't change its major version unless I ask. - Keep dark mode working on every page you touch. ## Step 4 — Polish and launch - Remove demo content and every CSS/JS file nothing uses any more; optimise images. - Check phone, tablet and desktop widths, labels, alt text, keyboard focus and colour contrast. - Run the production build and tell me which folder to deploy. - Keep the license file and credit the author of Next Elite. ## Ground rules Work in small steps and show me each change. Use only the libraries already in the project unless I agree to add one.






