DEV Community

Cover image for I Built a CLI to Scaffold Next.js Apps with Any Stack — No More Boilerplate Hell
Mohammed Samrose
Mohammed Samrose

Posted on

I Built a CLI to Scaffold Next.js Apps with Any Stack — No More Boilerplate Hell

Every time I started a new Next.js project, I found myself doing the same thing: installing Prisma, wiring up NextAuth, setting up Zustand, configuring tRPC, and copy-pasting Docker files from my last project. It's not hard work — it's tedious work. And after doing it for the fifth time, I decided to stop.

That's how create-samrose-app was born — an opinionated CLI that scaffolds a fully configured Next.js project with your exact stack choices, all in a single command.


The Problem with Boilerplate

Most Next.js starters fall into one of two traps:

  1. Too opinionated — you're locked into one ORM, one auth library, one everything. Swap anything out and you're on your own.
  2. Too bare — you get a blank canvas with zero integrations, and you're back to manually wiring things up.

What I wanted was something in the middle: a CLI that asks what I want, then builds it — correctly wired, production-ready, no leftover config to clean up.


What create-samrose-app Does

Run a single command:

npx create-samrose-app
Enter fullscreen mode Exit fullscreen mode

Then you get an interactive prompt that walks you through your stack:

? Project name › my-app
? Select ORM › Prisma
? Select Database › PostgreSQL
? Select Auth › NextAuth
? Select UI Library › shadcn/ui
? Select State Management › Zustand
? Select API Layer › tRPC
? Select Testing › Vitest
? Extras › Docker, GitHub Actions, Husky
Enter fullscreen mode Exit fullscreen mode

And that's it. Your project is scaffolded, every piece talking to every other piece, ready for npm run dev.


What's Supported

ORM

  • Prisma — schema-first, great DX, strong TypeScript support
  • Drizzle — lightweight, SQL-like syntax, gaining fast adoption
  • TypeORM — decorator-based, familiar if you're coming from the Java/Spring world
  • Mongoose — for MongoDB-native workflows

Database

  • PostgreSQL
  • MySQL
  • SQLite
  • MongoDB

Authentication

  • NextAuth — the community standard for Next.js auth
  • Clerk — drop-in auth with UI components
  • JWT — roll your own, full control

State Management

  • Zustand
  • Redux
  • Recoil

API Layer

  • tRPC — end-to-end typesafe APIs, no REST or GraphQL schema boilerplate
  • oRPC — a newer alternative worth watching
  • GraphQL
  • REST

Testing

  • Jest
  • Vitest

Extras

  • Docker — containerize from day one
  • GitHub Actions — CI/CD out of the box
  • Husky — pre-commit hooks for lint and type checks

How It Works Under the Hood

The CLI is built with Node.js and uses a prompt-driven approach to collect your choices. Based on your selections, it:

  1. Copies a base Next.js template
  2. Conditionally injects the right dependencies into package.json
  3. Scaffolds config files (e.g., prisma/schema.prisma, drizzle.config.ts, auth.ts, trpc/router.ts)
  4. Wires integrations together — for example, if you pick tRPC + Prisma + PostgreSQL, the router already has a database client initialized
  5. Sets up extras like Dockerfile, .github/workflows/ci.yml, and .husky/pre-commit

Every combination is tested to work together — you're not getting a patchwork of copy-pasted snippets.


A Real Example

Say you pick: Drizzle + PostgreSQL + Clerk + tRPC + Zustand + Vitest + Docker.

You'll get:

my-app/
├── src/
│   ├── app/              # Next.js App Router
│   ├── server/
│   │   ├── db/           # Drizzle schema + client
│   │   └── api/          # tRPC routers
│   ├── store/            # Zustand stores
│   └── middleware.ts     # Clerk auth middleware
├── drizzle.config.ts
├── .env.example          # All required env vars listed
├── Dockerfile
└── vitest.config.ts
Enter fullscreen mode Exit fullscreen mode

The .env.example is pre-populated with every variable your stack needs — no hunting through docs to figure out what's required.


Why Not Just Use create-t3-app?

T3 Stack is excellent and was a big inspiration. But it's tightly coupled to its own set of choices (tRPC + Prisma + NextAuth + Tailwind). If you want Drizzle instead of Prisma, or Clerk instead of NextAuth, or Zustand instead of nothing — you're doing manual surgery.

create-samrose-app is built around flexibility. Every layer of the stack is a choice, and every combination is first-class.


Try It

npx create-samrose-app
Enter fullscreen mode Exit fullscreen mode

What's Next

There are a few things on the roadmap:

  • Payload CMS integration for headless CMS setups
  • Turborepo support for monorepo scaffolding
  • Storybook as an extras option
  • A --yes flag for non-interactive scaffolding with defaults

If you try it and hit something broken, or have a stack combination you'd love to see supported, open an issue on GitHub. PRs are welcome too — the more combinations that get tested in the wild, the better.


Building create-samrose-app saved me hours on every new project. Hopefully it does the same for you.

Top comments (0)