create-davbyte-mfe
v1.20260301.1
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: use defaults (port 3400, 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
- Auth – Global
AuthContext,useAuthhook,AuthGuardthat gates access by app scope (usesauth_tokencookie) - Testing – Vitest with
testandtest:ciscripts, plus example tests
Prompts
When scaffolding interactively, you'll be asked:
- Port – Dev server port (default: 3400)
- Keep default basePath? – If yes, uses
/apps/{mfe-name}innext.config.tsandlib/auth.ts. If no, omits basePath for standalone deployment. - Autolink to client dashboard? – If a
client/src/lib/mfe-config.tsexists (monorepo layout), registers the MFE in the client's config with dev/staging/production URLs and origins.
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.
