Skip to content

Repository files navigation

Next.js 16 Template

Next.js 16 - a modern template repo

A Next.js 16 template with modern tooling and CI/CD automation. Code quality checks (linting, formatting, type checking, testing) run via Lefthook locally and GitHub Actions on PRs. Dependency updates automated via Dependabot. Deployments handled by Vercel: Preview for PRs, Production for main. Assumes Claude Code.

Homepage in light and dark modes with UI library guidance

Template homepage with light/dark mode setup — UI component library still needed

See this template live — https://nextjs-base-hello.vercel.app

🎯 Use This Template

(1) Get This Repo. Click "Use this template" → creates a new repository on your GitHub with no commit history — a fresh start. Then clone it locally:

git clone https://github.com/YOUR-USERNAME/YOUR-REPO.git
cd YOUR-REPO
# Install dependencies
npm install
# For Claude Code typescript-lsp plugin
npm install -g typescript-language-server typescript
# Claude Code uses for browser exploration (Global chosen)
npm install -g @playwright/cli@latest
# Ensure latest Playwright CLI skill
playwright-cli install --skills
# Open http://localhost:3000 to see app running
npm run dev

(2) Install Extensions. In VSCode/Cursor install the extensions shown in .vscode/extensions.json

(3) GitHub + Vercel Setup. Follow xdocs/project-setup.md to set up GitHub and Vercel.

(4) Housekeeping. Recommended to remove xdocs/ (these are my working files). Modify .claude/CLAUDE.md, .mcp.json, and .claude/settings.json as preferred — note the latter installs my plugins and marketplaces into your clone, manage them with /plugins.

(5) Choose UI Library. Choose one that supports Tailwind 4. shadcn/ui (free) and HeroUI v3 (free) are both LLM friendly and use semantic tokens — which makes theming easy. shadcn is ubiquitous so theme it well to stand out — tweak-cn and theme-generator are helpful. HeroUI is more visually distinct and extremely LLM friendly; it ships with agent skills too. Tailwind Plus (paid) offers components (Catalyst), assembled UI blocks, and full site templates, but doesn't include semantic tokens so centralised theming takes more manual work.

(6) Decide on Icons. Each UI library above ships with icons — shadcn/ui uses Lucide React, Tailwind Plus (Catalyst) uses Heroicons, HeroUI uses Iconify. All three let you swap to a different icon library.

(7) Replace Template Files. Replace app/page.tsx, app/layout.tsx, components/button.tsx, app/globals.css (centralised theming), app/fonts.ts, and components/theme-toggle.tsx (use an icon).

What's Installed?

For exact list see package.json

CategoryToolWhat it does
RuntimeNode.js 24 LTSPinned via .nvmrc; engines in package.json bounds it to the 24 line
FrameworkNext.js 16.3Core webapp foundation — routing, rendering, API routes, optimisation, and builds
LanguageTypeScript 7Static type checking with strict mode enabled — native Go compiler, ~5x faster
StylingTailwind CSS v4Utility-first CSS framework for rapid styling
next-themesLight/dark mode theming provider
LintingBiomeFast linter and formatter (replaces ESLint + Prettier)
markdownlint-cli2Lints markdown files for consistent formatting
TestingVitestFast unit test runner (Vite-native, Jest-compatible)
PlaywrightE2E browser testing (Chromium, Firefox, WebKit, Mobile)
Testing LibraryReact component testing utilities
Git HooksLefthookRuns checks on commit (lint, typecheck, unit tests) and push (build, E2E tests)
OptimisationReact CompilerAutomatic memoisation and performance optimisations
AnalyticsVercel Speed InsightsReal user performance metrics viewable on Vercel
Vercel Web AnalyticsPrivacy-friendly visitor analytics viewable on Vercel

Common Additions for New Projects

When starting a new project from this template, you'll typically add:

  • UI components (shadcn/ui, HeroUI v3, Tailwind Plus, etc.)
  • State management (Zustand, Jotai, or React Context)
  • Data fetching (React Query, SWR, or native fetch with Server Components)
  • Forms (React Hook Form, Zod for validation)
  • Authentication (NextAuth.js, Clerk, or Supabase Auth)
  • Database/ORM (Neon or Supabase with Prisma or Drizzle. Or try Convex!)

Explained banner

Next.js Installation Explained

This template was initialised with the following options and then updated:

# Next.js installer
$ npx create-next-app@latest
Would you like to use TypeScript? ✔️ Yes
Which linter would you like to use? ✔️ Biome
Would you like to use React Compiler? ✔️ Yes
Would you like to use Tailwind CSS? ✔️ Yes
Would you like your code inside a src/ directory? ❌ No
Would you like to use App Router? (recommended) ✔️ Yes
Would you like to customise the import alias (@/* by default)? ❌ No
# Update all dependencies to latest versions
npm outdated # Check outdated packages (2025-11-20)
npx npm-check-updates -u # Rewrite package.json with latest
npm install # Install updated versions

Config Files Explained

FileWhatGenerally In This Project Template
.gitattributesGit line ending and file type handlingNormalises line endings across platforms for consistent Git diffs
.gitignoreFiles and directories Git should ignorePrevents build outputs and dependencies from being committed
.markdownlint-cli2.yamlMarkdownlint configurationDisables strict linting rules for practical writing; supports file ignores
.nvmrcNode.js version pinSingle source for the Node major — CI reads it via node-version-file, nvm use reads it locally
.vscode/extensions.jsonVS Code extension recommendationsUseful extensions to use in this Next.js project
.vscode/settings.jsonVS Code editor and formatting settingsEnables auto-formatting and configures Biome and Tailwind extensions
🌺 .claude/rules/Claude Code context-aware rulesAuto-injected when editing matching file paths
🌺 .claude/settings.jsonClaude Code permissions + pluginsAllow/Deny permissions, plus enabled plugins and marketplaces
🌺 .mcp.jsonClaude Code MCP configRef MCP for docs search
🌺 .claude/CLAUDE.mdClaude Code project contextDocuments tech stack for Claude Code (customise!)
🅽 next.config.tsNext.js framework configurationEnables React Compiler and customises Next.js build settings
🅽 package.jsonProject dependencies and npm scriptsDefines project dependencies, scripts, and npm package metadata
🅽 postcss.config.mjsPostCSS plugins config for CSS processingEnables Tailwind CSS v4 processing via PostCSS plugin
🧪 biome.jsonBiome linter and formatterSets linting rules, formatting style, and import organisation
🧪 lefthook.ymlGit hooks managerAutomates code quality checks on commit and build + E2E tests on push
🧪 tsconfig.jsonTypeScript compiler settingsConfigures TypeScript compiler options and module resolution behaviour
🧪 playwright.config.tsPlaywright E2E test runner configurationSets test browsers (desktop + mobile), parallel execution, and base URLs
🧪 .playwright/Playwright test outputs (custom organisation)Contains test artifacts in test-results/ and HTML playwright-report/ (all Playwright outputs nested under .playwright/ for clean structure)
🧪 vitest.config.tsVitest test runner configSets up React component testing environment and references vitest.setup.ts
🧪 vitest.setup.tsGlobal test setupAdds helpful test assertions like expect(element).toBeVisible()
🚀 .github/dependabot.ymlDependabot configAutomated dependency update PRs weekly (npm + GitHub Actions)
🚀 .github/workflows/check-lint-type.ymlGitHub Actions CI workflowRuns Biome linting/formatting checks and TypeScript type checking on PRs
🚀 .github/workflows/test-e2e.ymlGitHub Actions CI workflowRuns Playwright E2E tests on PRs (builds production, tests browsers, uploads reports)
🚀 .github/workflows/test-e2e-vercel.ymlGitHub Actions CI workflowRuns Playwright E2E tests against Vercel Preview deployments (triggered by Vercel)
🚀 .github/workflows/test-unit.ymlGitHub Actions CI workflowRuns Vitest unit tests on PRs (uses jsdom environment, React Testing Library)

CI/CD Workflow Explained

This diagram shows how CI automation integrates into a typical development workflow:

┌─────────────────────────────────────────────────────────────────────────────┐
│ 💻 LAPTOP: Create a new branch (tests on local dev machine)
└─────────────────────────────────────────────────────────────────────────────┘
git checkout -b feature/add-dark-mode
│
├─ Commit 1: Add light/dark mode ⚡ pre-commit hook runs (3s)
│ ├─ 🎨 Biome lint and format ✅ Auto-fixed & staged
│ ├─ 🔍 TypeScript type check ✅ Pass
│ └─ 🧪 Vitest unit tests ✅ Pass
│ (then committed on all pass)
│
├─ Commit 2: (some more work here) ⚡ pre-commit hook runs again
│
└─ Commit 3: (some more work here) ⚡ pre-commit hook runs again
git push origin feature/add-dark-mode ⚡ pre-PUSH hook runs (~20s)
├─ 🏗️ Next.js production build ✅ Pass
└─ 🎭 Playwright E2E tests ✅ Pass (then pushed to GH)
┌─────────────────────────────────────────────────────────────────────────────┐
│ ☁️ GITHUB: Workflows kickoff on GitHub machines when PR is created
└─────────────────────────────────────────────────────────────────────────────┘
Create Pull Request → GitHub Actions triggered automatically
│
├─ 🤖 Workflow 1: Lint & Type (biome, tsc)
│ ├─ Checkout code
│ ├─ Setup Node.js (from .nvmrc)
│ ├─ Install dependencies (npm ci)
│ ├─ Run Biome checks ✅ Pass
│ └─ Run TypeScript checks ✅ Pass
│
├─ 🤖 Workflow 2: Unit Tests (vitest)
│ ├─ Checkout code
│ ├─ Setup Node.js (from .nvmrc)
│ ├─ Install dependencies (npm ci)
│ └─ Run Vitest tests ✅ Pass
│
└─ 🤖 Workflow 3: E2E Tests (playwright)
├─ Checkout code
├─ Setup Node.js (from .nvmrc)
├─ Install dependencies (npm ci)
├─ Install Playwright browsers
├─ Build Next.js production
└─ Run Playwright tests ✅ Pass
── Meanwhile, Vercel deploys Preview ──────────────────────────
🚀 Vercel: Preview deployment ready
├─ ✅ Vercel deployment status check (required to merge)
└─ Sends repository_dispatch event to GitHub
└─ 🤖 Workflow 4: E2E Tests (Vercel Preview)
├─ Triggered by Vercel (not PR event)
├─ Runs Playwright against live Preview URL
├─ Tests real Vercel deployment ✅ Pass
└─ Reports status back to PR commit
GITHUB PR Status: ✅ All checks passed
🐰 CodeRabbit AI Review Complete
└─ 3 nitpick comments posted:
├─ "Consider using const instead of let" (Button.tsx:12)
├─ "Add JSDoc comment" (ThemeContext.tsx:8)
└─ "Extract magic string to constant" (utils.ts:45)
┌─────────────────────────────────────────────────────────────────────────────┐
│ 💻 Back to Laptop (Addressing 1 out of 3 nitpick comments on open PR)
└─────────────────────────────────────────────────────────────────────────────┘
├─ Commit 4: Use const instead of let ⚡ pre-commit hook runs
git push origin feature/add-dark-mode ⚡ pre-push hook runs (~20s)
├─ 🏗️ Next.js production build ✅ Pass
└─ 🎭 Playwright E2E tests ✅ Pass (then pushed to GH)
┌─────────────────────────────────────────────────────────────────────────────┐
│ ☁️ GITHUB (Workflows kick off again on any PR changes)
└─────────────────────────────────────────────────────────────────────────────┘
New commits pushed → GitHub Actions re-run automatically
│
├─ 🤖 Lint & Type ✅ Pass
├─ 🤖 Unit Tests ✅ Pass
└─ 🤖 E2E Tests ✅ Pass
PR Status: ✅ All checks passed (1 new commit)
🐰 CodeRabbit: "Looks good! 1 issue resolved."
Okay I'm ready! [Merge Pull Request] ← Click! 🎉
┌─────────────────────────────────────────────┐
│ Ruleset Verified: "Protect main branch" │
│ ✅ All 5 required status checks passed │
│ ✅ Branch is up to date with main │
└─────────────────────────────────────────────┘
main branch updated (merge commit preserves 4 commits)
└─ 🚀 Vercel deployment triggered → Production

Key CI Takeaways

  • Local Hooks — Catch issues before commit or reaching GitHub
  • GitHub Actions — Validate every PR with fresh environment (reproducible CI)
  • GitHub Ruleset — Prevents merging broken code (all checks must pass)
  • Fast Feedback — Pre-commit catches 90% of issues locally in ~3s vs ~2min CI wait
  • Quality Gates — Code is validated 2× (local + CI) before reaching production

Quick rough notes

Quick Notes

(1) How Vitest Pieces Work Together

1. When you run npm test, Vitest loads vitest.config.ts
2. The config tells Vitest to use jsdom and load `vitest.setup.ts`3. Your test files can use global test functions and extended matchers
4. The @/* import alias works in tests thanks to `vite-tsconfig-paths`5. React components are compiled with React Compiler (matching prod)

(2) GitHub - A branch ruleset to be set up to protect main. Includes checks for GitHub workflow jobs to pass before merging PR to main. See xdocs/project-setup.md.

(3) Vercel For Deploys - When you raise a PR it automatically deploys to Vercel Preview and Playwright e2e tests run on that too in addition to GitHub servers. When you merge the PR into main, you are deploying to Vercel prod. See xdocs/project-setup.md.

(4) Claude Code Plugins - Declared under enabledPlugins in .claude/settings.json. A plugin set to false is installed but switched off — deliberate, not broken. Switch one on via /plugin only when you actually need it, since every enabled plugin adds always-on context to each session (claude plugin details <name>@<marketplace> shows the token cost).

About

Next.js16 template with modern tooling, automated testing, CI/CD via GitHub Actions, deploy to Vercel

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages