A CLI-based meta-framework for scaffolding Next.js apps with custom stacks. Build your projects faster with an opinionated setup that includes your choice of database ORM, authentication, and mailing capabilities.
- Next.js - Start with a modern Next.js 14+ app using the App Router
- ️ Database Options - Choose between Prisma (type-safe ORM) or Drizzle (lightweight SQL ORM)
- Authentication - Optional NextAuth.js integration with database adapters
- Mailing - Optional email capabilities with React Email and Nodemailer
- Styling - Tailwind CSS pre-configured and ready to use
- Modular - Add features to existing projects when you need them
# Install globally using pnpm
pnpm add -g create-my-stack
# Or run directly with pnpm
pnpm dlx create-my-stack
# Run the CLI and follow the interactive prompts
create-my-stack
You'll be guided through a series of prompts to customize your stack:
- Project name
- Database ORM (Prisma or Drizzle)
- Authentication with NextAuth.js (optional)
- Mailing capabilities (optional)
You can add features to an existing Next.js project:
# Add NextAuth to an existing project
create-my-stack add nextauth
# Add mailing capabilities to an existing project
create-my-stack add mailing
For CI/CD or automation, you can skip prompts with the --yes
flag and provide options directly:
create-my-stack --yes --name=my-app --db=prisma --auth --mailing
Your configuration is saved as a .stackrc
file in the project directory. You can reuse this for future projects.
- Next.js 14+ with App Router
- TypeScript configuration
- ESLint setup
- Tailwind CSS
- Prisma: Type-safe ORM with auto-generated migrations
- Drizzle: Lightweight SQL ORM with type safety
- NextAuth.js with GitHub and Google providers
- Database adapter integration (Prisma or Drizzle)
- Sign-in page
- React Email components
- Nodemailer integration
- Sample email templates
- shadcn/ui: Beautifully designed components built with Radix UI and Tailwind CSS
- Chakra UI: Simple, modular component library with great accessibility
The CLI is built with a modular template system that combines different features based on user selection:
templates/
├── base/ # Base Next.js template with Tailwind CSS
├── prisma/ # Prisma ORM configuration and schema
├── drizzle/ # Drizzle ORM setup and schema
├── nextauth/ # NextAuth.js authentication
├── mailing/ # Email capabilities with React Email
├── shadcn/ # shadcn/ui components configuration
├── chakra/ # Chakra UI provider setup
├── nextui/ # NextUI components and theme setup
└── shared/ # Common files for all templates
To develop and test the CLI locally:
- Clone the repository:
git clone https://github.com/yourusername/create-my-stack.git
cd create-my-stack
- Install dependencies:
pnpm install
- Build the project:
pnpm run build
- Test the CLI locally (using the built-in script):
pnpm run local-test
- For testing the add command:
pnpm run local-add-test
Here's a description of all available scripts in the project:
dev
: Watch for file changes and compile TypeScript in real-timebuild
: Compile TypeScript to JavaScriptstart
: Run the compiled CLI directlylint
: Run ESLint on all TypeScript filestest
: Run all tests using Vitesttest:watch
: Run tests in watch mode during developmentlocal-test
: Build the project and run the CLI locallylocal-add-test
: Build the project and test the "add" commandlink
: Build and create a global symlink for testingchangeset
: Create a new changeset to record changesversion
: Update versions and changelogs based on changesetsrelease
: Build the project and publish to npm registry
pnpm run local-test
# One-time setup for pnpm global bin directory
pnpm setup
# Restart your terminal or source your profile
source ~/.zshrc # for zsh users
# Then link the package
pnpm run link
# Build the project
pnpm run build
# Link using npm instead
npm link
# Build first
pnpm run build
# Run directly with Node
node dist/index.js
# Create and enter a test directory
mkdir test-dir && cd test-dir
# Run the CLI from parent directory
node ../dist/index.js
The project uses Vitest for testing. To run tests:
# Run all tests once
pnpm test
# Run tests in watch mode during development
pnpm test:watch
# Run a specific test file
pnpm test -- tests/stackrc.test.ts
# Run a specific test suite (describe block)
pnpm test -- -t "stackrc configuration"
# Run a specific test (it block)
pnpm test -- -t "should load configuration from a .stackrc file"
# Run tests with coverage report
pnpm test -- --coverage
tests/cli.test.ts
- Tests for core CLI functionalitytests/args.test.ts
- Tests for command-line argument parsingtests/stackrc.test.ts
- Tests for .stackrc configuration loading and usage
Contributions are welcome! Here's how you can contribute:
- Create a new folder in the
templates/
directory - Add the necessary files and configurations
- Update the template selection in
src/index.ts
- Add the template merging logic in
src/utils/project.ts
- Add new test files in the
tests/
directory - Follow the existing test patterns using Vitest
- Test different combinations of features and edge cases
- Run the test suite to verify your changes
- Fork the repository
- Create a feature branch
- Add your changes and tests
- Submit a pull request with a clear description of your changes
This project uses changesets to manage versions, create changelogs, and publish to npm. Here's how the publishing workflow works:
When you make changes to the codebase that require a version bump, create a changeset:
pnpm changeset
This command will prompt you to:
- Select which packages need to be updated (select
create-my-stack
) - Choose the type of version bump (major, minor, or patch)
- Write a summary of the changes
The command creates a markdown file in the .changeset
directory with your changelog entry.
When you're ready to release, update the versions based on the changesets:
pnpm version
This command:
- Removes the changeset files
- Updates
package.json
with the new version - Updates the
CHANGELOG.md
file with the changes
Finally, to publish to npm:
# Make sure you're logged in to npm
npm login
# Build and publish
pnpm release
This will build the package and publish it to the npm registry.
Here's the complete process for releasing a new version:
- Create changesets for your changes (
pnpm changeset
) - Update versions based on changesets (
pnpm version
) - Commit the version updates (
git commit -am "Version packages"
) - Tag the release (
git tag v0.1.1
) - Push changes and tags (
git push && git push --tags
) - Publish to npm (
pnpm release
)
MIT