create-restack-pattern
v0.1.8
Published
Scaffold a new Next.js + Hono + Drizzle monorepo using the Restack Pattern (Semi-DDD) template.
Downloads
31
Readme
create-restack-pattern
Skip the boilerplate — scaffold a full-stack Next.js + Hono + PostgreSQL monorepo with secure auth cookies, structured logging, and a type-safe Hono RPC client end-to-end, all wired up and ready to deploy.
This is the official initializer for the Restack Pattern.
Usage
npx create-restack-pattern my-appOr run it without arguments to be prompted for a project name:
npx create-restack-patternPrerequisites
- Node.js: version 20 or higher
- pnpm: package manager installed (run
npm install -g pnpmif needed) - PostgreSQL: a running database (either a local instance or a free hosted instance on Neon)
Quick Start (Next Steps)
Once the CLI finishes scaffolding your project, follow these three simple steps to get started:
1. Configure Environment Variables
cd my-app
cp backend/.env.example backend/.env
cp frontend/.env.example frontend/.env- Open
backend/.envand set:DATABASE_URL(format:postgresql://user:password@localhost:5432/dbname; you can use a local Postgres database or a free hosted instance on Neon)JWT_SECRET(generate a secure 32-character key by running:openssl rand -base64 32)
- (Optional) Open
frontend/.envto overrideNEXT_PUBLIC_API_URL(defaults tohttp://localhost:3001for local Hono API).
2. Push Database Tables
This creates the required users and auth_sessions tables in your database:
pnpm --filter backend db:push3. Start Development Servers
pnpm dev- Backend API: runs at http://localhost:3001
- Frontend App: runs at http://localhost:3000
What You Get
frontend/— Next.js 16 (App Router)backend/— Hono + Drizzle ORM, with a working JWT + refresh-token auth flow, production-ready structured correlation logging (Pino + Hono request tracing), and an exampleuserdomain already wired up.packages/shared/— Zod schemas shared between frontend and backend.
For a full breakdown of the folder structure, architecture rules (Semi-DDD), dual-cookie auth implementation, and deployment verification checklists, please visit the GitHub repository.
For Maintainers (Local Dev & Publishing)
The template/ directory in this package is a copy of frontend/, backend/, and packages/shared/ from the repo root, not a live reference — and it's gitignored.
Before testing your CLI changes locally or publishing, follow the standard workflow:
- Sync template:
pnpm --filter create-restack-pattern sync-template - Compile the CLI script:
pnpm --filter create-restack-pattern build - Verify the published files:
npm pack --dry-run - Scaffold locally to test:
node dist/index.js test-app - Publish to npm:
Bump the
"version"inpackage.json, then:npm publish
For detailed guides, workflow explanations, and lessons learned:
- Check out the Development Guide (Indonesian: Panduan Kontribusi)
