The shared core: auth, roles, Prisma, mock payments/email, admin shell, SEO, CI and Docker.
Find a file Use this template
w4c-templates 81b42bc31a
Some checks failed
CI / quality (push) Has been cancelled
chore(template): publish Base.Next
2026-10-11 23:32:13 +03:00
.github/workflows chore(template): publish Base.Next 2026-10-11 23:23:30 +03:00
.w4c chore(template): publish Base.Next 2026-10-11 23:23:30 +03:00
app chore(template): publish Base.Next 2026-10-11 23:23:30 +03:00
components chore(template): publish Base.Next 2026-10-11 23:23:30 +03:00
docker chore(template): publish Base.Next 2026-10-11 23:23:30 +03:00
lib chore(template): publish Base.Next 2026-10-11 23:23:30 +03:00
messages chore(template): publish Base.Next 2026-10-11 23:23:30 +03:00
prisma chore(template): publish Base.Next 2026-10-11 23:23:30 +03:00
public chore(template): publish Base.Next 2026-10-11 23:23:30 +03:00
tests chore(template): publish Base.Next 2026-10-11 23:23:30 +03:00
.dockerignore chore(template): publish Base.Next 2026-10-11 23:23:30 +03:00
.env.example chore(template): publish Base.Next 2026-10-11 23:23:30 +03:00
.eslintrc.json chore(template): publish Base.Next 2026-10-11 23:23:30 +03:00
.gitignore chore(template): publish Base.Next 2026-10-11 23:23:30 +03:00
middleware.ts chore(template): publish Base.Next 2026-10-11 23:23:30 +03:00
next.config.ts chore(template): publish Base.Next 2026-10-11 23:23:30 +03:00
package-lock.json chore(template): publish Base.Next 2026-10-11 23:23:30 +03:00
package.json chore(template): publish Base.Next 2026-10-11 23:23:30 +03:00
postcss.config.mjs chore(template): publish Base.Next 2026-10-11 23:23:30 +03:00
README.md chore(template): publish Base.Next 2026-10-11 23:23:30 +03:00
tsconfig.json chore(template): publish Base.Next 2026-10-11 23:23:30 +03:00
vitest.config.ts chore(template): publish Base.Next 2026-10-11 23:23:30 +03:00

Base — Next.js (templates2)

A ready-to-run Next.js (App Router) base application. It is the shared core every Next.js v2 case forks: authentication, roles, Prisma, mock payments and email, an admin shell, SEO, i18n, observability, CI and a Docker image — all working on the first run.

Not listed in the user catalog ("catalog": false in .w4c/template.json); it exists to be forked by cases such as Store.Next or Saas.Next.

Quickstart

npm ci
cp .env.example .env          # SQLite + mock providers by default — no keys needed
npm run db:setup              # prisma db push + seed
npm run dev                   # http://localhost:3000

Demo accounts (seeded): admin@example.com (admin) and user@example.com (user) — password password.

Scripts

Script What it does
npm run dev Dev server with HMR
npm run build / npm start Production build / serve
npm run lint / npm run typecheck ESLint / tsc --noEmit
npm test Unit tests (Vitest)
npm run test:e2e HTTP end-to-end smoke (server must be running)
npm run db:setup prisma db push + seed
npm run db:seed Seed only

What works out of the box

  • Auth & roles — email + password, bcrypt, httpOnly cookie sessions (Session table), user and admin roles, server-side guards (requireUser, requireAdmin) and API authorization.
  • Payments — a provider interface with a mock provider that needs no keys and activates the subscription immediately, plus a Stripe provider that turns on when STRIPE_SECRET_KEY is set. Webhooks are signature-checked and idempotent.
  • Email — a log provider by default, Resend when RESEND_API_KEY is set.
  • Admin — role-gated shell, overview dashboard, users table (role change / delete with confirmation) and an audit log.
  • SEO — per-route metadata, OpenGraph, JSON-LD, sitemap.xml, robots.txt.
  • i18n — English dictionary in messages/en.json, looked up via t().
  • Observability — /api/health, error boundary and loading/empty states.
  • Delivery — multi-stage Dockerfile with a healthcheck, and CI running lint + typecheck + unit
    • build + e2e.

Data model

prisma/schema.prisma: User, Session, Subscription, AuditLog. SQLite in development; point DATABASE_URL at Postgres for production.

Deployment

docker compose -f docker/docker-compose.yml up --build

Quality

node ../templates2/qa.mjs Base.Next        # from the repo root: node templates2/qa.mjs Base.Next

The harness isolates a clean copy, then runs install → verify → test → build → boot → routes → e2e → screenshot. See ../CONTRACT.md for the Definition of Done.