<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Salman Shahriar</title>
    <description>The latest articles on DEV Community by Salman Shahriar (@salmanshahriar).</description>
    <link>https://dev.to/salmanshahriar</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1951722%2F6c136fda-088e-4813-ba06-de1af03134ea.jpeg</url>
      <title>DEV Community: Salman Shahriar</title>
      <link>https://dev.to/salmanshahriar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/salmanshahriar"/>
    <language>en</language>
    <item>
      <title>I built a production ready NEXT.JS starter so you dont have to!</title>
      <dc:creator>Salman Shahriar</dc:creator>
      <pubDate>Sun, 21 Jun 2026 22:32:59 +0000</pubDate>
      <link>https://dev.to/salmanshahriar/i-built-a-production-ready-nextjs-starter-so-you-dont-have-to-2khp</link>
      <guid>https://dev.to/salmanshahriar/i-built-a-production-ready-nextjs-starter-so-you-dont-have-to-2khp</guid>
      <description>&lt;p&gt;Every time I started a new Next.js project, I lost the first week to setup.&lt;/p&gt;

&lt;p&gt;Authentication. Internationalization. Role-based access. SEO meta tags. Environment validation. Error monitoring. Linting. Testing. CI pipelines.&lt;/p&gt;

&lt;p&gt;By the time I had a working foundation, the excitement was gone, buried under configuration files and boilerplate glue code.&lt;/p&gt;

&lt;p&gt;I kept rebuilding the same foundation across SaaS projects, so I stopped and built it once: &lt;strong&gt;&lt;a href="https://github.com/salmanshahriar/Next-Elite" rel="noopener noreferrer"&gt;Next Elite&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It is a frontend-first Next.js 16 + React 19 boilerplate designed to consume APIs (REST/GraphQL/BFF) instead of owning a database, allowing you to drop it on top of any backend you already have. It is optimized for speed, SEO, and developer productivity, and it is 100% open source under the MIT license.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://next-elite-boilerplate.vercel.app/" rel="noopener noreferrer"&gt;Live Demo&lt;/a&gt;&lt;/strong&gt; · &lt;strong&gt;&lt;a href="https://github.com/salmanshahriar/Next-Elite" rel="noopener noreferrer"&gt;GitHub Repo&lt;/a&gt;&lt;/strong&gt; · &lt;strong&gt;&lt;a href="https://github.com/salmanshahriar/Next-Elite/generate" rel="noopener noreferrer"&gt;Use This Template&lt;/a&gt;&lt;/strong&gt; · &lt;strong&gt;&lt;a href="https://vercel.com/new/clone?repository-url=https://github.com/salmanshahriar/Next-Elite" rel="noopener noreferrer"&gt;Deploy on Vercel&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv9ccdc9cf650sv06i200.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv9ccdc9cf650sv06i200.png" alt="Next.js Elite production-ready SaaS boilerplate cover" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;TL;DR:&lt;/strong&gt; &lt;code&gt;git clone&lt;/code&gt;, &lt;code&gt;npm install&lt;/code&gt;, &lt;code&gt;cp .env.example .env&lt;/code&gt;, &lt;code&gt;npm run dev&lt;/code&gt;. You get auth, RBAC dashboards, 6-language i18n, SEO, forms, testing, and CI. &lt;a href="https://next-elite-boilerplate.vercel.app/" rel="noopener noreferrer"&gt;Try the demo&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Why Another Next.js Boilerplate? (The Concept)&lt;/li&gt;
&lt;li&gt;What's Inside: The Next Elite Stack &amp;amp; Features&lt;/li&gt;
&lt;li&gt;Lighthouse Score: 100% Performance &amp;amp; SEO&lt;/li&gt;
&lt;li&gt;Quick Start: Launch Your Project in 60 Seconds&lt;/li&gt;
&lt;li&gt;Deep Dive: How Next Elite Works Under the Hood&lt;/li&gt;
&lt;li&gt;Clean Feature-Based Directory Structure&lt;/li&gt;
&lt;li&gt;Architectural Caveats: What Next Elite is NOT&lt;/li&gt;
&lt;li&gt;Production Checklist: Going Live&lt;/li&gt;
&lt;li&gt;Contributing &amp;amp; Open Source&lt;/li&gt;
&lt;/ol&gt;




&lt;h2 id="why-another-nextjs-boilerplate"&gt;1. Why Another Next.js Boilerplate? (The Concept)&lt;/h2&gt;

&lt;p&gt;Most Next.js starters on GitHub are either too bare (providing just a dark mode toggle and a "TODO: add auth" comment) or too bloated (bundling Prisma, PostgreSQL, Docker Compose, stripe webhooks, and an ORM tightly coupled to their own DB schema).&lt;/p&gt;

&lt;p&gt;If you already have a backend (written in Go, Python, Laravel, or Node.js) or want to build a backend-for-frontend (BFF) architecture, tearing out the built-in database layer from a boilerplate is painful.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Next Elite sits in the sweet spot.&lt;/strong&gt; It handles the complex frontend foundation, UI components, role management, and locale settings while leaving the database and api fetching structure flexible. It’s built to consume APIs directly, allowing you to drop it on top of any backend you already have.&lt;/p&gt;

&lt;h3&gt;
  
  
  Who is this boilerplate for?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  ✅ &lt;strong&gt;SaaS applications&lt;/strong&gt; requiring complex role authorization.&lt;/li&gt;
&lt;li&gt;  ✅ &lt;strong&gt;Internationalized projects&lt;/strong&gt; that need to support multiple languages (LTR and RTL).&lt;/li&gt;
&lt;li&gt;  ✅ &lt;strong&gt;Frontend-first architectures&lt;/strong&gt; consuming REST, GraphQL, or a backend-for-frontend (BFF).&lt;/li&gt;
&lt;li&gt;  ❌ &lt;strong&gt;Single-page landing websites&lt;/strong&gt; (Next Elite is likely overkill).&lt;/li&gt;
&lt;li&gt;  ❌ &lt;strong&gt;Tightly-coupled monoliths&lt;/strong&gt; requiring a database layer in the same repository.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2 id="whats-inside"&gt;2. What's Inside: The Next Elite Stack &amp;amp; Features&lt;/h2&gt;

&lt;p&gt;Here is the clean, high-performance tech stack built into Next Elite, broken down by core categories:&lt;/p&gt;

&lt;h3&gt;
  
  
  Frameworks &amp;amp; Core
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Next.js 16 (App Router)&lt;/strong&gt; &amp;amp; &lt;strong&gt;React 19&lt;/strong&gt; – Fast, modern React framework with full support for React 19 features (Server/Client components, Server Actions).&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;TypeScript 6&lt;/strong&gt; – End-to-end type safety for rock-solid refactoring and developer experience.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Node.js 22 (LTS)&lt;/strong&gt; – Built on the latest LTS runtime.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Feature-Based Architecture&lt;/strong&gt; – Structured around self-contained vertical slices/feature folders under &lt;code&gt;src/features/&lt;/code&gt; for maximum modularity and clean separation of concerns.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Authentication &amp;amp; Access Control
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;BetterAuth&lt;/strong&gt; – Out-of-the-box email/password and OAuth (Google) authentication using &lt;code&gt;/api/auth/*&lt;/code&gt; route handlers. Configure admin emails via &lt;code&gt;AUTH_ADMIN_EMAILS&lt;/code&gt; or &lt;code&gt;NEXT_PUBLIC_AUTH_ADMIN_EMAILS&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Role-Based Access Control (RBAC)&lt;/strong&gt; – Flexible RBAC (&lt;code&gt;user&lt;/code&gt; and &lt;code&gt;admin&lt;/code&gt; roles) with server-side guards (&lt;code&gt;requireUser&lt;/code&gt;, &lt;code&gt;requirePermission&lt;/code&gt;) and parallel route slots (&lt;code&gt;@admin&lt;/code&gt;, &lt;code&gt;@user&lt;/code&gt;) for role-agnostic routing.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Internationalization (i18n)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;next-intl&lt;/strong&gt; – Type-safe, cookie-based localizations (no URL prefix) with support for English, বাংলা, العربية (RTL), Français, Español, and 简体中文. Translation keys are type-checked (&lt;code&gt;t("key")&lt;/code&gt; works; typos fail compile-time).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  UI &amp;amp; Styling
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;shadcn/ui&lt;/strong&gt; – Highly customizable UI components built with Tailwind CSS, Radix UI, and CVA.&lt;/p&gt;


  &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fnext-elite-boilerplate.vercel.app%2FNextjs-Elite-UI-Image.webp" alt="Next Elite UI Components" width="800" height="600"&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Theme Support&lt;/strong&gt; – Clean light/dark mode transitions via theme toggle.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  API &amp;amp; Data Fetching
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;TanStack Query (React Query)&lt;/strong&gt; – Powerful client-side state management, caching, and data synchronization.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;apiFetch Client&lt;/strong&gt; – A custom Zod-validated &lt;code&gt;ofetch&lt;/code&gt; wrapper in &lt;code&gt;src/libs/api-client.ts&lt;/code&gt; supporting type-safe queries and mutations. Includes a complete &lt;code&gt;users&lt;/code&gt; example feature.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Observability &amp;amp; Infrastructure
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Sentry Integration&lt;/strong&gt; – Complete error tracking and performance instrumentation for client and server.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Logging&lt;/strong&gt; – Clean, fast server-side logging using &lt;code&gt;pino&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Rate Limiting&lt;/strong&gt; – Optional rate-limiting helper using Upstash Redis.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Health Probes&lt;/strong&gt; – Direct &lt;code&gt;GET /api/health&lt;/code&gt; endpoint for load balancers.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Quality Gates &amp;amp; Tooling
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Testing Suite&lt;/strong&gt; – Unit/component testing with Vitest and React Testing Library, and E2E testing with Playwright.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Hygiene &amp;amp; Linting&lt;/strong&gt; – ESLint 9, Prettier formatting, and Knip for dead code/dependency hygiene.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Git Hook Automation&lt;/strong&gt; – Lefthook pre-commit hooks and Commitlint to maintain codebase quality.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2 id="lighthouse-score"&gt;3. Lighthouse Score: 100% Performance &amp;amp; SEO&lt;/h2&gt;

&lt;p&gt;One of the key goals of Next Elite was achieving flawless performance and SEO defaults. Out-of-the-box, the production build scores a perfect &lt;strong&gt;100&lt;/strong&gt; across the board on Lighthouse:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0lkfe6bd7g51y5rmwbnz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0lkfe6bd7g51y5rmwbnz.png" alt="Next Elite Lighthouse Report - 100 Performance, Accessibility, Best Practices, and SEO" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is achieved by rendering Server Components by default, minimizing client-side javascript, optimizing images, and dynamically serving optimized SEO meta tags from a single configuration file.&lt;/p&gt;




&lt;h2 id="quick-start"&gt;4. Quick Start: Launch Your Project in 60 Seconds&lt;/h2&gt;

&lt;h3&gt;
  
  
  Local Setup
&lt;/h3&gt;

&lt;p&gt;Getting started is simple. Clone the repository, install dependencies, copy environment variables, and run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/salmanshahriar/Next-Elite.git
&lt;span class="nb"&gt;cd &lt;/span&gt;Next-Elite
npm &lt;span class="nb"&gt;install
cp&lt;/span&gt; .env.example .env
npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open &lt;a href="http://localhost:3000" rel="noopener noreferrer"&gt;http://localhost:3000&lt;/a&gt; to see your app running locally.&lt;/p&gt;

&lt;h3&gt;
  
  
  Demo Credentials
&lt;/h3&gt;

&lt;p&gt;When &lt;code&gt;NEXT_PUBLIC_DEMO_MODE=true&lt;/code&gt; is enabled, the login screen includes a quick-fill panel with these seed credentials:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Role&lt;/th&gt;
&lt;th&gt;Email&lt;/th&gt;
&lt;th&gt;Password&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;User&lt;/td&gt;
&lt;td&gt;&lt;code&gt;user@test.com&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;12345678&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Admin&lt;/td&gt;
&lt;td&gt;&lt;code&gt;admin@test.com&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;12345678&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;[!NOTE]&lt;br&gt;
For production deployments, set &lt;code&gt;NEXT_PUBLIC_DEMO_MODE=false&lt;/code&gt; or remove the self-contained &lt;code&gt;src/features/auth/demo/&lt;/code&gt; module.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Docker Setup
&lt;/h3&gt;

&lt;p&gt;Run the application locally via Docker:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cp&lt;/span&gt; .env.example .env
docker build &lt;span class="nt"&gt;-t&lt;/span&gt; next-elite &lt;span class="nb"&gt;.&lt;/span&gt;
docker run &lt;span class="nt"&gt;--rm&lt;/span&gt; &lt;span class="nt"&gt;--env-file&lt;/span&gt; .env &lt;span class="nt"&gt;-p&lt;/span&gt; 3000:3000 next-elite
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or using Docker Compose:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker compose up &lt;span class="nt"&gt;--build&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;b&gt;View Available Scripts &amp;amp; CLI Commands&lt;/b&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;npm run dev&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Start the dev server (Turbopack)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;npm run build&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Production build&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;npm run start&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Start the production server&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;npm run analyze&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Build with &lt;code&gt;@next/bundle-analyzer&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;npm run typecheck&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tsc --noEmit&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;npm run lint&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;ESLint + Prettier check&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;npm run lint:fix&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Auto-fix ESLint + Prettier&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;npm run knip&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Detect unused files / exports / dependencies&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;npm run check&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;typecheck + lint + knip + tests (CI gate)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;npm run test&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Vitest run&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;npm run test:watch&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Vitest watch&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;npm run e2e&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Playwright E2E&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;npm run e2e:ui&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Playwright UI mode&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;npm run e2e:webkit&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Playwright WebKit only&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2 id="deep-dive"&gt;5. Deep Dive: How Next Elite Works Under the Hood&lt;/h2&gt;

&lt;h3&gt;
  
  
  Architecture &amp;amp; Request Flow
&lt;/h3&gt;

&lt;p&gt;Next Elite separates server-side security checks from client-side interactive components. Here is how a request flows:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl2hw4cliyj28zrlkvast.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl2hw4cliyj28zrlkvast.png" alt="Next Elite Architecture Flow" width="800" height="516"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;User opens a page&lt;/strong&gt; — the Server Component renders first.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Auth + role check&lt;/strong&gt; — &lt;code&gt;requireUser()&lt;/code&gt; / &lt;code&gt;requirePermission()&lt;/code&gt; read the BetterAuth session and redirect to &lt;code&gt;/login&lt;/code&gt; or &lt;code&gt;/unauthorized&lt;/code&gt; if needed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;HTML is sent&lt;/strong&gt; to the browser; translations come from &lt;code&gt;messages/&lt;/code&gt; via &lt;code&gt;next-intl&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Live data&lt;/strong&gt; (lists, forms, etc.) is fetched on the client with TanStack Query → &lt;code&gt;apiFetch&lt;/code&gt; → your API.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  🔐 Type-Safe RBAC &amp;amp; BetterAuth
&lt;/h3&gt;

&lt;p&gt;Permissions are checked on the server, not with scattered &lt;code&gt;if (role === 'admin')&lt;/code&gt; checks.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;View Auth &amp;amp; RBAC Usage Example&lt;/b&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Server Component example&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;requirePermission&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@/features/auth/rbac/require&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;AdminDashboardPage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;amp;&lt;/span&gt;&lt;span class="nx"&gt;gt&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Guard the page on the server. If fails, it automatically redirects or errors.&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;requirePermission&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dashboard.view:admin&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Welcome&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;AdminDashboardPage&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Next Elite utilizes Next.js &lt;strong&gt;Parallel Routes&lt;/strong&gt; to clean up role-agnostic layouts. The routing structure mounts specific slots based on the user's role:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;src/app/(protected)/
  ├── @admin/dashboard/     # Admin dashboard slot
  ├── @user/dashboard/      # User dashboard slot
  └── layout.tsx            # Dynamically renders the correct dashboard
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;b&gt;Adding a New Role&lt;/b&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Append the role to the &lt;code&gt;UserRole&lt;/code&gt; union in &lt;code&gt;src/features/auth/rbac/permissions.ts&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Map permissions for the role in &lt;code&gt;src/features/auth/rbac/roles.ts&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Optional: add a parallel route slot — &lt;code&gt;src/app/(protected)/@/...&lt;/code&gt; — and update &lt;code&gt;(protected)/layout.tsx&lt;/code&gt; to render it based on permissions.&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  🌐 Zero-Prefix cookie-based i18n
&lt;/h3&gt;

&lt;p&gt;Unlike standard i18n configurations that force prefixes like &lt;code&gt;/en/&lt;/code&gt; or &lt;code&gt;/es/&lt;/code&gt; in the URL (which can clutter routes and create duplicate routing configurations), Next Elite implements zero-prefix cookie-based locales.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Adding a Language&lt;/b&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Add the locale code to &lt;code&gt;languages.supported&lt;/code&gt; in &lt;code&gt;site.config.json&lt;/code&gt; and add an entry under &lt;code&gt;languages.locales&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Create &lt;code&gt;messages/.json&lt;/code&gt; mirroring &lt;code&gt;messages/en.json&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;next-intl&lt;/code&gt; runtime picks it up automatically; types update from &lt;code&gt;src/global.d.ts&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  📈 Site &amp;amp; SEO Configuration
&lt;/h3&gt;

&lt;p&gt;SEO parameters, sitemap generation, and manifests are driven by &lt;code&gt;src/features/site/site.config.json&lt;/code&gt; as the single source of truth:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"appName"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Next Elite"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"domain"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"https://yourdomain.com"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"tagline"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Frontend-first, API-driven, batteries included."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"title"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Next Elite — Production-Ready SaaS Boilerplate"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"description"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Frontend-first Next.js 16 + React 19 boilerplate with i18n, RBAC and BetterAuth."&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  📡 API client &amp;amp; Data Validation
&lt;/h3&gt;

&lt;p&gt;The custom &lt;code&gt;apiFetch&lt;/code&gt; client in &lt;code&gt;src/libs/api-client.ts&lt;/code&gt; uses &lt;code&gt;ofetch&lt;/code&gt; and integrates with &lt;code&gt;Zod&lt;/code&gt; validation. This guarantees type-safe request schemas and API responses.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;View API Fetch &amp;amp; Form Usage Examples&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;API Request:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// src/features/users/api.ts&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getUsers&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;apiFetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/users&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;schema&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;userListSchema&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Client Form with Zod validation:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;use client&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;zodResolver&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@hookform/resolvers/zod&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useForm&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react-hook-form&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;loginSchema&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;LoginInput&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@/features/auth/schemas/login&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;form&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useForm&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;resolver&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;zodResolver&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;loginSchema&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="na"&gt;defaultValues&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2 id="project-structure"&gt;6. Clean Feature-Based Directory Structure&lt;/h2&gt;

&lt;p&gt;Next Elite uses a &lt;strong&gt;Feature-Based (Vertical Slice) Architecture&lt;/strong&gt; under &lt;code&gt;src/features/&lt;/code&gt;. Each folder contains its own API requests, components, hooks, schemas, and routing logic. Shared utilities live under &lt;code&gt;src/libs/&lt;/code&gt; or &lt;code&gt;src/components/shared/&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Expand Directory Structure View&lt;/b&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.
├── .github/
│   └── workflows/            # CI: lint, typecheck, tests, Playwright
├── config/                   # Vitest config &amp;amp;amp; test setup
├── e2e/                      # Playwright E2E tests
├── messages/                 # Translation JSONs (en, bn, ar, fr, es, zh)
├── public/                   # Static assets
├── src/
│   ├── app/                  # Next.js App Router Pages &amp;amp;amp; Layouts
│   │   ├── (auth)/           # Auth views (login, register, reset password)
│   │   ├── (public)/         # Public landing and marketing routes
│   │   └── (protected)/      # Protected area rendering slot-based RBAC
│   ├── components/
│   │   ├── shared/           # Cross-app reusable components
│   │   └── ui/               # shadcn UI primitive elements
│   ├── features/             # Self-contained feature folders (vertical slices)
│   │   ├── auth/             # BetterAuth configurations &amp;amp;amp; role management
│   │   ├── i18n/             # next-intl bootstrap and hooks
│   │   ├── site/             # Site details &amp;amp;amp; SEO configuration
│   │   └── users/            # Example modular API feature
│   └── libs/                 # Core wrapper clients (api-client, logger, env)
└── package.json              # Script configurations &amp;amp;amp; dependencies
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2 id="architectural-caveats"&gt;7. Architectural Caveats: What Next Elite is NOT&lt;/h2&gt;

&lt;p&gt;To keep the boilerplate clean and adaptable, I made specific design trade-offs:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;No Database Bundled:&lt;/strong&gt; There is no Prisma, Drizzle, Postgres, or MongoDB setup. Next Elite is built to communicate with an external API. If you need local mock data or a quick mock DB, you'll need to hook that up.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Simple RBAC System:&lt;/strong&gt; The starter RBAC covers two roles (&lt;code&gt;user&lt;/code&gt; and &lt;code&gt;admin&lt;/code&gt;) with a fast-path admin list via environment variables. For complex multi-tenant permissions, we recommend mapping roles on your main database and API layer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cookie-Based i18n:&lt;/strong&gt; By storing user localization choice in a cookie rather than a path-prefix (like &lt;code&gt;/en/dashboard&lt;/code&gt;), routes remain simpler, but path-prefixed SEO indexing for multiple locales will require a custom router setup.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Local BetterAuth Sessions:&lt;/strong&gt; By default, session keys run locally. A session adapter is recommended for production setups using multiple server instances.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2 id="production-checklist"&gt;8. Production Checklist: Going Live&lt;/h2&gt;

&lt;p&gt;Before deploying Next Elite to production, run through these essential configuration steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Configure Auth Secrets:&lt;/strong&gt; Set &lt;code&gt;BETTER_AUTH_SECRET&lt;/code&gt; (at least 32 characters long) in your hosting dashboard.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Add a Session Storage Adapter:&lt;/strong&gt; BetterAuth requires an external database or Redis adapter to manage server sessions in multi-instance production environments.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Disable Demo Mode:&lt;/strong&gt; Set &lt;code&gt;NEXT_PUBLIC_DEMO_MODE=false&lt;/code&gt; or completely delete the &lt;code&gt;src/features/auth/demo/&lt;/code&gt; folder.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Link Your API:&lt;/strong&gt; Implement your backend endpoints or update &lt;code&gt;NEXT_PUBLIC_APP_URL&lt;/code&gt; to point to your live REST/GraphQL/BFF service.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Update SEO Metadata:&lt;/strong&gt; Change &lt;code&gt;site.config.json&lt;/code&gt; with your project domain name, official OG image, and app description.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Activate Logging &amp;amp; Error Tracing:&lt;/strong&gt; Add Sentry and Pino configurations to track errors in real-time.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2 id="contributing"&gt;9. Contributing &amp;amp; Open Source&lt;/h2&gt;

&lt;p&gt;Next Elite is free and open-source under the MIT license. Contributions, bug reports, and discussions are welcome!&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Fork the repository and create a feature branch (&lt;code&gt;git checkout -b feat/my-feature&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Ensure linting, types, and tests pass by running &lt;code&gt;npm run check&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Follow the &lt;strong&gt;Conventional Commits&lt;/strong&gt; standard (which is automatically validated via Lefthook pre-commit hooks).&lt;/li&gt;
&lt;li&gt;Create a Pull Request back to the &lt;code&gt;main&lt;/code&gt; branch.&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  If this starter boilerplate saves you development time, consider giving the repo a star! ⭐
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://next-elite-boilerplate.vercel.app/" rel="noopener noreferrer"&gt;Live Demo&lt;/a&gt;&lt;/strong&gt; · &lt;strong&gt;&lt;a href="https://github.com/salmanshahriar/Next-Elite" rel="noopener noreferrer"&gt;GitHub Repo&lt;/a&gt;&lt;/strong&gt; · &lt;strong&gt;&lt;a href="https://github.com/salmanshahriar/Next-Elite/generate" rel="noopener noreferrer"&gt;Use Template&lt;/a&gt;&lt;/strong&gt; · &lt;strong&gt;&lt;a href="https://vercel.com/new/clone?repository-url=https://github.com/salmanshahriar/Next-Elite" rel="noopener noreferrer"&gt;Deploy on Vercel&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>react</category>
      <category>boilerplate</category>
      <category>betterauth</category>
    </item>
    <item>
      <title>I built a production ready NEXT.JS Boilerplate so you dont have to!</title>
      <dc:creator>Salman Shahriar</dc:creator>
      <pubDate>Wed, 19 Nov 2025 19:11:28 +0000</pubDate>
      <link>https://dev.to/salmanshahriar/i-built-a-production-ready-nextjs-boilerplate-so-you-dont-have-to-17d3</link>
      <guid>https://dev.to/salmanshahriar/i-built-a-production-ready-nextjs-boilerplate-so-you-dont-have-to-17d3</guid>
      <description>&lt;p&gt;Every time I started a new Next.js project, I lost the first week to setup.&lt;/p&gt;

&lt;p&gt;Authentication. Internationalization. Role-based access. SEO meta tags. Environment validation. Error monitoring. Linting. Testing. CI pipelines.&lt;/p&gt;

&lt;p&gt;By the time I had a working foundation, the excitement was gone, buried under configuration files and boilerplate glue code.&lt;/p&gt;

&lt;p&gt;I kept rebuilding the same foundation across SaaS projects, so I stopped and built it once: &lt;strong&gt;&lt;a href="https://github.com/salmanshahriar/Next-Elite" rel="noopener noreferrer"&gt;Next Elite&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It is a frontend-first Next.js 16 + React 19 boilerplate designed to consume APIs (REST/GraphQL/BFF) instead of owning a database, allowing you to drop it on top of any backend you already have. It is optimized for speed, SEO, and developer productivity, and it is 100% open source under the MIT license.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://next-elite-boilerplate.vercel.app/" rel="noopener noreferrer"&gt;Live Demo&lt;/a&gt;&lt;/strong&gt; · &lt;strong&gt;&lt;a href="https://github.com/salmanshahriar/Next-Elite" rel="noopener noreferrer"&gt;GitHub Repo&lt;/a&gt;&lt;/strong&gt; · &lt;strong&gt;&lt;a href="https://github.com/salmanshahriar/Next-Elite/generate" rel="noopener noreferrer"&gt;Use This Template&lt;/a&gt;&lt;/strong&gt; · &lt;strong&gt;&lt;a href="https://vercel.com/new/clone?repository-url=https://github.com/salmanshahriar/Next-Elite" rel="noopener noreferrer"&gt;Deploy on Vercel&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv9ccdc9cf650sv06i200.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv9ccdc9cf650sv06i200.png" alt="Next.js Elite production-ready SaaS boilerplate cover" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;TL;DR:&lt;/strong&gt; &lt;code&gt;git clone&lt;/code&gt;, &lt;code&gt;npm install&lt;/code&gt;, &lt;code&gt;cp .env.example .env&lt;/code&gt;, &lt;code&gt;npm run dev&lt;/code&gt;. You get auth, RBAC dashboards, 6-language i18n, SEO, forms, testing, and CI. &lt;a href="https://next-elite-boilerplate.vercel.app/" rel="noopener noreferrer"&gt;Try the demo&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Why Another Next.js Boilerplate? (The Concept)&lt;/li&gt;
&lt;li&gt;What's Inside: The Next Elite Stack &amp;amp; Features&lt;/li&gt;
&lt;li&gt;Lighthouse Score: 100% Performance &amp;amp; SEO&lt;/li&gt;
&lt;li&gt;Quick Start: Launch Your Project in 60 Seconds&lt;/li&gt;
&lt;li&gt;Deep Dive: How Next Elite Works Under the Hood&lt;/li&gt;
&lt;li&gt;Clean Feature-Based Directory Structure&lt;/li&gt;
&lt;li&gt;Architectural Caveats: What Next Elite is NOT&lt;/li&gt;
&lt;li&gt;Production Checklist: Going Live&lt;/li&gt;
&lt;li&gt;Contributing &amp;amp; Open Source&lt;/li&gt;
&lt;/ol&gt;




&lt;h2 id="why-another-nextjs-boilerplate"&gt;1. Why Another Next.js Boilerplate? (The Concept)&lt;/h2&gt;

&lt;p&gt;Most Next.js starters on GitHub are either too bare (providing just a dark mode toggle and a "TODO: add auth" comment) or too bloated (bundling Prisma, PostgreSQL, Docker Compose, stripe webhooks, and an ORM tightly coupled to their own DB schema).&lt;/p&gt;

&lt;p&gt;If you already have a backend (written in Go, Python, Laravel, or Node.js) or want to build a backend-for-frontend (BFF) architecture, tearing out the built-in database layer from a boilerplate is painful.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Next Elite sits in the sweet spot.&lt;/strong&gt; It handles the complex frontend foundation, UI components, role management, and locale settings while leaving the database and api fetching structure flexible. It’s built to consume APIs directly, allowing you to drop it on top of any backend you already have.&lt;/p&gt;

&lt;h3&gt;
  
  
  Who is this boilerplate for?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  ✅ &lt;strong&gt;SaaS applications&lt;/strong&gt; requiring complex role authorization.&lt;/li&gt;
&lt;li&gt;  ✅ &lt;strong&gt;Internationalized projects&lt;/strong&gt; that need to support multiple languages (LTR and RTL).&lt;/li&gt;
&lt;li&gt;  ✅ &lt;strong&gt;Frontend-first architectures&lt;/strong&gt; consuming REST, GraphQL, or a backend-for-frontend (BFF).&lt;/li&gt;
&lt;li&gt;  ❌ &lt;strong&gt;Single-page landing websites&lt;/strong&gt; (Next Elite is likely overkill).&lt;/li&gt;
&lt;li&gt;  ❌ &lt;strong&gt;Tightly-coupled monoliths&lt;/strong&gt; requiring a database layer in the same repository.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2 id="whats-inside"&gt;2. What's Inside: The Next Elite Stack &amp;amp; Features&lt;/h2&gt;

&lt;p&gt;Here is the clean, high-performance tech stack built into Next Elite, broken down by core categories:&lt;/p&gt;

&lt;h3&gt;
  
  
  Frameworks &amp;amp; Core
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Next.js 16 (App Router)&lt;/strong&gt; &amp;amp; &lt;strong&gt;React 19&lt;/strong&gt; – Fast, modern React framework with full support for React 19 features (Server/Client components, Server Actions).&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;TypeScript 6&lt;/strong&gt; – End-to-end type safety for rock-solid refactoring and developer experience.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Node.js 22 (LTS)&lt;/strong&gt; – Built on the latest LTS runtime.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Feature-Based Architecture&lt;/strong&gt; – Structured around self-contained vertical slices/feature folders under &lt;code&gt;src/features/&lt;/code&gt; for maximum modularity and clean separation of concerns.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Authentication &amp;amp; Access Control
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;BetterAuth&lt;/strong&gt; – Out-of-the-box email/password and OAuth (Google) authentication using &lt;code&gt;/api/auth/*&lt;/code&gt; route handlers. Configure admin emails via &lt;code&gt;AUTH_ADMIN_EMAILS&lt;/code&gt; or &lt;code&gt;NEXT_PUBLIC_AUTH_ADMIN_EMAILS&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Role-Based Access Control (RBAC)&lt;/strong&gt; – Flexible RBAC (&lt;code&gt;user&lt;/code&gt; and &lt;code&gt;admin&lt;/code&gt; roles) with server-side guards (&lt;code&gt;requireUser&lt;/code&gt;, &lt;code&gt;requirePermission&lt;/code&gt;) and parallel route slots (&lt;code&gt;@admin&lt;/code&gt;, &lt;code&gt;@user&lt;/code&gt;) for role-agnostic routing.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Internationalization (i18n)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;next-intl&lt;/strong&gt; – Type-safe, cookie-based localizations (no URL prefix) with support for English, বাংলা, العربية (RTL), Français, Español, and 简体中文. Translation keys are type-checked (&lt;code&gt;t("key")&lt;/code&gt; works; typos fail compile-time).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  UI &amp;amp; Styling
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;shadcn/ui&lt;/strong&gt; – Highly customizable UI components built with Tailwind CSS, Radix UI, and CVA.&lt;/p&gt;


  &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fnext-elite-boilerplate.vercel.app%2FNextjs-Elite-UI-Image.webp" alt="Next Elite UI Components" width="800" height="600"&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Theme Support&lt;/strong&gt; – Clean light/dark mode transitions via theme toggle.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  API &amp;amp; Data Fetching
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;TanStack Query (React Query)&lt;/strong&gt; – Powerful client-side state management, caching, and data synchronization.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;apiFetch Client&lt;/strong&gt; – A custom Zod-validated &lt;code&gt;ofetch&lt;/code&gt; wrapper in &lt;code&gt;src/libs/api-client.ts&lt;/code&gt; supporting type-safe queries and mutations. Includes a complete &lt;code&gt;users&lt;/code&gt; example feature.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Observability &amp;amp; Infrastructure
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Sentry Integration&lt;/strong&gt; – Complete error tracking and performance instrumentation for client and server.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Logging&lt;/strong&gt; – Clean, fast server-side logging using &lt;code&gt;pino&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Rate Limiting&lt;/strong&gt; – Optional rate-limiting helper using Upstash Redis.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Health Probes&lt;/strong&gt; – Direct &lt;code&gt;GET /api/health&lt;/code&gt; endpoint for load balancers.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Quality Gates &amp;amp; Tooling
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Testing Suite&lt;/strong&gt; – Unit/component testing with Vitest and React Testing Library, and E2E testing with Playwright.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Hygiene &amp;amp; Linting&lt;/strong&gt; – ESLint 9, Prettier formatting, and Knip for dead code/dependency hygiene.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Git Hook Automation&lt;/strong&gt; – Lefthook pre-commit hooks and Commitlint to maintain codebase quality.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2 id="lighthouse-score"&gt;3. Lighthouse Score: 100% Performance &amp;amp; SEO&lt;/h2&gt;

&lt;p&gt;One of the key goals of Next Elite was achieving flawless performance and SEO defaults. Out-of-the-box, the production build scores a perfect &lt;strong&gt;100&lt;/strong&gt; across the board on Lighthouse:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0lkfe6bd7g51y5rmwbnz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0lkfe6bd7g51y5rmwbnz.png" alt="Next Elite Lighthouse Report - 100 Performance, Accessibility, Best Practices, and SEO" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is achieved by rendering Server Components by default, minimizing client-side javascript, optimizing images, and dynamically serving optimized SEO meta tags from a single configuration file.&lt;/p&gt;




&lt;h2 id="quick-start"&gt;4. Quick Start: Launch Your Project in 60 Seconds&lt;/h2&gt;

&lt;h3&gt;
  
  
  Local Setup
&lt;/h3&gt;

&lt;p&gt;Getting started is simple. Clone the repository, install dependencies, copy environment variables, and run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/salmanshahriar/Next-Elite.git
&lt;span class="nb"&gt;cd &lt;/span&gt;Next-Elite
npm &lt;span class="nb"&gt;install
cp&lt;/span&gt; .env.example .env
npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open &lt;a href="http://localhost:3000" rel="noopener noreferrer"&gt;http://localhost:3000&lt;/a&gt; to see your app running locally.&lt;/p&gt;

&lt;h3&gt;
  
  
  Demo Credentials
&lt;/h3&gt;

&lt;p&gt;When &lt;code&gt;NEXT_PUBLIC_DEMO_MODE=true&lt;/code&gt; is enabled, the login screen includes a quick-fill panel with these seed credentials:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Role&lt;/th&gt;
&lt;th&gt;Email&lt;/th&gt;
&lt;th&gt;Password&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;User&lt;/td&gt;
&lt;td&gt;&lt;code&gt;user@test.com&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;12345678&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Admin&lt;/td&gt;
&lt;td&gt;&lt;code&gt;admin@test.com&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;12345678&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;[!NOTE]&lt;br&gt;
For production deployments, set &lt;code&gt;NEXT_PUBLIC_DEMO_MODE=false&lt;/code&gt; or remove the self-contained &lt;code&gt;src/features/auth/demo/&lt;/code&gt; module.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Docker Setup
&lt;/h3&gt;

&lt;p&gt;Run the application locally via Docker:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cp&lt;/span&gt; .env.example .env
docker build &lt;span class="nt"&gt;-t&lt;/span&gt; next-elite &lt;span class="nb"&gt;.&lt;/span&gt;
docker run &lt;span class="nt"&gt;--rm&lt;/span&gt; &lt;span class="nt"&gt;--env-file&lt;/span&gt; .env &lt;span class="nt"&gt;-p&lt;/span&gt; 3000:3000 next-elite
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or using Docker Compose:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker compose up &lt;span class="nt"&gt;--build&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;b&gt;View Available Scripts &amp;amp; CLI Commands&lt;/b&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;npm run dev&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Start the dev server (Turbopack)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;npm run build&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Production build&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;npm run start&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Start the production server&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;npm run analyze&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Build with &lt;code&gt;@next/bundle-analyzer&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;npm run typecheck&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tsc --noEmit&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;npm run lint&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;ESLint + Prettier check&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;npm run lint:fix&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Auto-fix ESLint + Prettier&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;npm run knip&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Detect unused files / exports / dependencies&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;npm run check&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;typecheck + lint + knip + tests (CI gate)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;npm run test&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Vitest run&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;npm run test:watch&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Vitest watch&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;npm run e2e&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Playwright E2E&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;npm run e2e:ui&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Playwright UI mode&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;npm run e2e:webkit&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Playwright WebKit only&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2 id="deep-dive"&gt;5. Deep Dive: How Next Elite Works Under the Hood&lt;/h2&gt;

&lt;h3&gt;
  
  
  Architecture &amp;amp; Request Flow
&lt;/h3&gt;

&lt;p&gt;Next Elite separates server-side security checks from client-side interactive components. Here is how a request flows:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl2hw4cliyj28zrlkvast.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl2hw4cliyj28zrlkvast.png" alt="Next Elite Architecture Flow" width="800" height="516"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;User opens a page&lt;/strong&gt; — the Server Component renders first.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Auth + role check&lt;/strong&gt; — &lt;code&gt;requireUser()&lt;/code&gt; / &lt;code&gt;requirePermission()&lt;/code&gt; read the BetterAuth session and redirect to &lt;code&gt;/login&lt;/code&gt; or &lt;code&gt;/unauthorized&lt;/code&gt; if needed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;HTML is sent&lt;/strong&gt; to the browser; translations come from &lt;code&gt;messages/&lt;/code&gt; via &lt;code&gt;next-intl&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Live data&lt;/strong&gt; (lists, forms, etc.) is fetched on the client with TanStack Query → &lt;code&gt;apiFetch&lt;/code&gt; → your API.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  🔐 Type-Safe RBAC &amp;amp; BetterAuth
&lt;/h3&gt;

&lt;p&gt;Permissions are checked on the server, not with scattered &lt;code&gt;if (role === 'admin')&lt;/code&gt; checks.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;View Auth &amp;amp; RBAC Usage Example&lt;/b&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Server Component example&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;requirePermission&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@/features/auth/rbac/require&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;AdminDashboardPage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;amp;&lt;/span&gt;&lt;span class="nx"&gt;gt&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Guard the page on the server. If fails, it automatically redirects or errors.&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;requirePermission&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dashboard.view:admin&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Welcome&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;AdminDashboardPage&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Next Elite utilizes Next.js &lt;strong&gt;Parallel Routes&lt;/strong&gt; to clean up role-agnostic layouts. The routing structure mounts specific slots based on the user's role:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;src/app/(protected)/
  ├── @admin/dashboard/     # Admin dashboard slot
  ├── @user/dashboard/      # User dashboard slot
  └── layout.tsx            # Dynamically renders the correct dashboard
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;b&gt;Adding a New Role&lt;/b&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Append the role to the &lt;code&gt;UserRole&lt;/code&gt; union in &lt;code&gt;src/features/auth/rbac/permissions.ts&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Map permissions for the role in &lt;code&gt;src/features/auth/rbac/roles.ts&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Optional: add a parallel route slot — &lt;code&gt;src/app/(protected)/@/...&lt;/code&gt; — and update &lt;code&gt;(protected)/layout.tsx&lt;/code&gt; to render it based on permissions.&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  🌐 Zero-Prefix cookie-based i18n
&lt;/h3&gt;

&lt;p&gt;Unlike standard i18n configurations that force prefixes like &lt;code&gt;/en/&lt;/code&gt; or &lt;code&gt;/es/&lt;/code&gt; in the URL (which can clutter routes and create duplicate routing configurations), Next Elite implements zero-prefix cookie-based locales.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Adding a Language&lt;/b&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Add the locale code to &lt;code&gt;languages.supported&lt;/code&gt; in &lt;code&gt;site.config.json&lt;/code&gt; and add an entry under &lt;code&gt;languages.locales&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Create &lt;code&gt;messages/.json&lt;/code&gt; mirroring &lt;code&gt;messages/en.json&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;next-intl&lt;/code&gt; runtime picks it up automatically; types update from &lt;code&gt;src/global.d.ts&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  📈 Site &amp;amp; SEO Configuration
&lt;/h3&gt;

&lt;p&gt;SEO parameters, sitemap generation, and manifests are driven by &lt;code&gt;src/features/site/site.config.json&lt;/code&gt; as the single source of truth:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"appName"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Next Elite"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"domain"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"https://yourdomain.com"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"tagline"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Frontend-first, API-driven, batteries included."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"title"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Next Elite — Production-Ready SaaS Boilerplate"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"description"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Frontend-first Next.js 16 + React 19 boilerplate with i18n, RBAC and BetterAuth."&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  📡 API client &amp;amp; Data Validation
&lt;/h3&gt;

&lt;p&gt;The custom &lt;code&gt;apiFetch&lt;/code&gt; client in &lt;code&gt;src/libs/api-client.ts&lt;/code&gt; uses &lt;code&gt;ofetch&lt;/code&gt; and integrates with &lt;code&gt;Zod&lt;/code&gt; validation. This guarantees type-safe request schemas and API responses.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;View API Fetch &amp;amp; Form Usage Examples&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;API Request:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// src/features/users/api.ts&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getUsers&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;apiFetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/users&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;schema&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;userListSchema&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Client Form with Zod validation:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;use client&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;zodResolver&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@hookform/resolvers/zod&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useForm&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react-hook-form&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;loginSchema&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;LoginInput&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@/features/auth/schemas/login&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;form&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useForm&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;resolver&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;zodResolver&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;loginSchema&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="na"&gt;defaultValues&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2 id="project-structure"&gt;6. Clean Feature-Based Directory Structure&lt;/h2&gt;

&lt;p&gt;Next Elite uses a &lt;strong&gt;Feature-Based (Vertical Slice) Architecture&lt;/strong&gt; under &lt;code&gt;src/features/&lt;/code&gt;. Each folder contains its own API requests, components, hooks, schemas, and routing logic. Shared utilities live under &lt;code&gt;src/libs/&lt;/code&gt; or &lt;code&gt;src/components/shared/&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Expand Directory Structure View&lt;/b&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.
├── .github/
│   └── workflows/            # CI: lint, typecheck, tests, Playwright
├── config/                   # Vitest config &amp;amp;amp; test setup
├── e2e/                      # Playwright E2E tests
├── messages/                 # Translation JSONs (en, bn, ar, fr, es, zh)
├── public/                   # Static assets
├── src/
│   ├── app/                  # Next.js App Router Pages &amp;amp;amp; Layouts
│   │   ├── (auth)/           # Auth views (login, register, reset password)
│   │   ├── (public)/         # Public landing and marketing routes
│   │   └── (protected)/      # Protected area rendering slot-based RBAC
│   ├── components/
│   │   ├── shared/           # Cross-app reusable components
│   │   └── ui/               # shadcn UI primitive elements
│   ├── features/             # Self-contained feature folders (vertical slices)
│   │   ├── auth/             # BetterAuth configurations &amp;amp;amp; role management
│   │   ├── i18n/             # next-intl bootstrap and hooks
│   │   ├── site/             # Site details &amp;amp;amp; SEO configuration
│   │   └── users/            # Example modular API feature
│   └── libs/                 # Core wrapper clients (api-client, logger, env)
└── package.json              # Script configurations &amp;amp;amp; dependencies
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2 id="architectural-caveats"&gt;7. Architectural Caveats: What Next Elite is NOT&lt;/h2&gt;

&lt;p&gt;To keep the boilerplate clean and adaptable, I made specific design trade-offs:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;No Database Bundled:&lt;/strong&gt; There is no Prisma, Drizzle, Postgres, or MongoDB setup. Next Elite is built to communicate with an external API. If you need local mock data or a quick mock DB, you'll need to hook that up.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Simple RBAC System:&lt;/strong&gt; The starter RBAC covers two roles (&lt;code&gt;user&lt;/code&gt; and &lt;code&gt;admin&lt;/code&gt;) with a fast-path admin list via environment variables. For complex multi-tenant permissions, we recommend mapping roles on your main database and API layer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cookie-Based i18n:&lt;/strong&gt; By storing user localization choice in a cookie rather than a path-prefix (like &lt;code&gt;/en/dashboard&lt;/code&gt;), routes remain simpler, but path-prefixed SEO indexing for multiple locales will require a custom router setup.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Local BetterAuth Sessions:&lt;/strong&gt; By default, session keys run locally. A session adapter is recommended for production setups using multiple server instances.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2 id="production-checklist"&gt;8. Production Checklist: Going Live&lt;/h2&gt;

&lt;p&gt;Before deploying Next Elite to production, run through these essential configuration steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Configure Auth Secrets:&lt;/strong&gt; Set &lt;code&gt;BETTER_AUTH_SECRET&lt;/code&gt; (at least 32 characters long) in your hosting dashboard.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Add a Session Storage Adapter:&lt;/strong&gt; BetterAuth requires an external database or Redis adapter to manage server sessions in multi-instance production environments.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Disable Demo Mode:&lt;/strong&gt; Set &lt;code&gt;NEXT_PUBLIC_DEMO_MODE=false&lt;/code&gt; or completely delete the &lt;code&gt;src/features/auth/demo/&lt;/code&gt; folder.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Link Your API:&lt;/strong&gt; Implement your backend endpoints or update &lt;code&gt;NEXT_PUBLIC_APP_URL&lt;/code&gt; to point to your live REST/GraphQL/BFF service.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Update SEO Metadata:&lt;/strong&gt; Change &lt;code&gt;site.config.json&lt;/code&gt; with your project domain name, official OG image, and app description.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Activate Logging &amp;amp; Error Tracing:&lt;/strong&gt; Add Sentry and Pino configurations to track errors in real-time.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2 id="contributing"&gt;9. Contributing &amp;amp; Open Source&lt;/h2&gt;

&lt;p&gt;Next Elite is free and open-source under the MIT license. Contributions, bug reports, and discussions are welcome!&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Fork the repository and create a feature branch (&lt;code&gt;git checkout -b feat/my-feature&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Ensure linting, types, and tests pass by running &lt;code&gt;npm run check&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Follow the &lt;strong&gt;Conventional Commits&lt;/strong&gt; standard (which is automatically validated via Lefthook pre-commit hooks).&lt;/li&gt;
&lt;li&gt;Create a Pull Request back to the &lt;code&gt;main&lt;/code&gt; branch.&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  If this starter boilerplate saves you development time, consider giving the repo a star! ⭐
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://next-elite-boilerplate.vercel.app/" rel="noopener noreferrer"&gt;Live Demo&lt;/a&gt;&lt;/strong&gt; · &lt;strong&gt;&lt;a href="https://github.com/salmanshahriar/Next-Elite" rel="noopener noreferrer"&gt;GitHub Repo&lt;/a&gt;&lt;/strong&gt; · &lt;strong&gt;&lt;a href="https://github.com/salmanshahriar/Next-Elite/generate" rel="noopener noreferrer"&gt;Use Template&lt;/a&gt;&lt;/strong&gt; · &lt;strong&gt;&lt;a href="https://vercel.com/new/clone?repository-url=https://github.com/salmanshahriar/Next-Elite" rel="noopener noreferrer"&gt;Deploy on Vercel&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>react</category>
      <category>boilerplate</category>
      <category>betterauth</category>
    </item>
  </channel>
</rss>
