create-davbyte-mfe
v1.20260522.2
Published
Scaffold DavByte micro-frontends with Next.js
Maintainers
Readme
create-davbyte-mfe
Scaffold DavByte micro-frontends with Next.js. Cross-platform CLI for Windows, macOS, and Linux.
Usage
npm create davbyte-mfe@latest <mfeName>Windows: If
npm createfails with "not recognized", usenpx create-davbyte-mfe@latest <mfeName>instead.
Options:
--ci– Non-interactive mode: auto-assign port (3401–3499), keep basePath, overwrite if exists. Useful for CI/automation.
Requirements
- Node.js 20+
- npm
Generated Project
Each scaffolded project includes:
- TypeScript – Full TypeScript setup
- Next.js App Router – App Router + TypeScript
- Cloudflare – OpenNext for Cloudflare Workers with
previewanddeployscripts - Tailwind CSS – DavByte theme with company colors
- shadcn/ui – Bundled base-nova preset with
lib/utils.ts, Button, and Card; dependencies resolved at scaffold time. In monorepos, install runs once at the workspace root viapnpm install. Add more components withpnpm dlx shadcn@latest add [component](ornpxoutside a pnpm workspace). - Auth – Global
AuthContext,useAuthhook,AuthGuardthat gates access by app scope (usesauth_tokencookie) - Testing – Vitest with
testandtest:ciscripts, plus example tests
Dependencies (Next.js, React, Cloudflare, Tailwind, Vitest, Testing Library, etc.) are resolved from the npm registry when you scaffold — latest patch within the configured Next.js major, with React and related packages matched to Next peer requirements. Auto-fixable audit issues are applied with npm audit fix (or pnpm audit --fix in monorepos).
Monorepo behavior
In a pnpm workspace with an apps/ folder, the CLI always scaffolds to apps/<mfeName> — whether you run it from the repo root or from apps/. Dependencies install via pnpm install at the workspace root. If client/src/lib/mfe-config.ts exists, the MFE is autolinked to the dashboard automatically.
Prompts
When scaffolding interactively, you are only prompted if port allocation fails or the target directory already exists.
Auth
- Token is read from the
auth_tokencookie (including HttpOnly via API route). - App scope is derived from the MFE name:
{mfeNameLowercaseNoSpaces}:user.
Example:"My Cool App"→"mycoolapp:user". - When using basePath, auth API requests use the MFE base path so they hit this app's API, not the host's.
Environment
A .env.local file is created with:
AUTH_API_URL="http://localhost:3201/api/auth"
NEXT_PUBLIC_AUTH_API_URL="http://localhost:3201/api/auth"Edit these URLs to match your auth API.
