@mstfucrr/create-next-template
v2.3.0
Published
A CLI tool to generate up-to-date, customizable Next.js (App Router) projects with Tailwind CSS v4, Prettier and other features.
Downloads
751
Maintainers
Readme
@mstfucrr/create-next-template
A CLI tool for scaffolding customizable Next.js (App Router) projects on up-to-date versions — TypeScript, Turbopack, and Tailwind CSS v4 out of the box, with optional Axios, Zod, React Hook Form, Shadcn UI, TanStack Query, and a proxy.ts-based authorization starter.
Table of Contents
Requirements
- Node.js
>=20.9.0 - pnpm (must be installed globally)
Installation
You can use this template in two ways:
Option 1: Using npx (Recommended)
npx @mstfucrr/create-next-templateOption 2: Global Installation
npm install -g @mstfucrr/create-next-template
create-my-next-templateUsage
Run the template using either method above.
The CLI will guide you through the following options:
- Project name
- Next.js version (defaults to
latest) - React Compiler (enabled by default, opt-out)
- Additional features:
- Axios for HTTP requests
- Zod for schema validation
- React Hook Form for form handling (+
@hookform/resolverswhen combined with Zod) - Shadcn UI for components
- TanStack Query (React Query) — automatically wraps
src/app/layout.tsxwith aQueryClientProvider(see below) - A minimal, working
proxy.ts-based authorization template (Next.js 16's replacement formiddleware.ts) - PostHog product analytics
- Husky + lint-staged for a pre-commit lint/format hook
- Playwright for end-to-end testing
The tool will automatically:
- Set up a Next.js (App Router) project with TypeScript, using Turbopack and Tailwind CSS v4 by default
- Add ESLint (flat config)
- Set up Prettier +
prettier-plugin-tailwindcss - Create a recommended folder structure, including
(public)/(private)route groups undersrc/appand anerror.tsx/global-error.tsxerror boundary - Add
.vscode/settings.json(format-on-save) and.vscode/extensions.json(recommended extensions) - Add a shared
src/hooks/useDebounce.tshook - Add a
.nvmrcpinned to Node 24 - Generate example service (
src/services/example.service.ts) and module (src/modules/example/) files so you can see how the two are meant to be structured (see Features below) — safe to delete once you don't need them - Install selected dependencies
- Work around pnpm 11's
strictDepBuildsdefault so native build scripts (e.g.sharp,@tailwindcss/oxide) install correctly
Once the installation is complete, navigate to your project:
cd your-project-name
pnpm devNote: Right after scaffolding, your editor may show
Cannot find name 'LayoutProps'(orPageProps) inlayout.tsx/page.tsx. These are Next.js's typed-routes ambient types, generated into.next/types/only afternext devornext buildhas run at least once — not an issue with the generated code. Runpnpm devonce, then restart your editor's TypeScript server (in VS Code: Cmd/Ctrl+Shift+P → "TypeScript: Restart TS Server") if the error persists.
Features
- ⚡ Next.js (App Router) with Turbopack and Tailwind CSS v4 out of the box
- 📝 TypeScript support
- 🎯 ESLint flat config (via
eslint-config-next) - 💅 Prettier + Tailwind class sorting, pre-configured for Tailwind v4
- 📦 PNPM package manager
- 🏗️ Recommended project structure, including
src/app/(public)/layout.tsxandsrc/app/(private)/layout.tsxroute groups (the existing home page is moved into(public)), anerror.tsx/global-error.tsxerror boundary, and a sharedsrc/hooks/useDebounce.tshook - 🔢
.nvmrcpinned to Node 24, generated in every project - 🧩 Example service & module scaffolding, generated in every project to illustrate the intended structure:
src/services/example.service.ts— a generic, shared service (fetches example users via Axios orfetch, depending on your Axios choice)src/modules/example/— a self-contained feature module with its owntypes/,services/,components/, anindex.tsxentry component, and (only if TanStack Query is selected) ahooks/useExampleQuery.tsbuilt onuseQuery- Both are safe to delete once you've built your own services/modules
- 🔧 Optional integrations:
- Axios
- Zod
- React Hook Form (with
@hookform/resolverswhen paired with Zod) - Shadcn UI
- TanStack Query, with a generated
src/components/providers/query-provider.tsx(Client Component) that automatically wrapslayout.tsx— if the generatedlayout.tsxdoesn't match the expected pattern, the provider file is still created and you wrap{children}with<QueryProvider>yourself. proxy.ts-based authorization starter (App Routersrc/proxy.ts)- React Compiler
- PostHog: a
src/components/providers/posthog-provider.tsx(Client Component) that wrapslayout.tsx's{children}automatically — this wrap works even if another provider (e.g. TanStack Query's) is already wrapping{children}. Also generates a committable.env.example(with a.gitignoreexception, since the project's default.env*rule would otherwise hide it) — copy it to.env.localand fill inNEXT_PUBLIC_POSTHOG_KEYto start tracking. - Husky + lint-staged: a
.husky/pre-commithook that runslint-staged(ESLint --fix + Prettier --write on staged files). Only wires upcore.hooksPathif the generated project has its own.gitdirectory. - Playwright:
playwright.config.ts+ an examplee2e/home.spec.ts, withtest:e2e/test:e2e:uiscripts. Browsers aren't downloaded automatically — runpnpm exec playwright installonce inside the generated project.
Development
Want to contribute to the CLI itself (not the projects it generates)? See CONTRIBUTING.md for local setup, testing, and lint/format instructions. Notable changes are tracked in CHANGELOG.md.
npm install
npm test # Vitest unit tests
npm run lint # ESLint
npm run format # PrettierLicense
MIT © Mustafa Uçar
