This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a monorepo for @vercel/microfrontends, a library that enables splitting large applications into independently developed and deployed microfrontends on Vercel. The package provides generic platform support for microfrontends in multiple frameworks, such as Next.js, SvelteKit, React Router, Vite, and React.
packages/microfrontends/- The main@vercel/microfrontendspackage (the only publishable package)examples/- Working examples of microfrontend implementations (nextjs-app, nextjs-pages, react-router, single-spa, sveltekit, etc.)
- This is a TypeScript codebase
- Use pnpm for package management
- Turbo manages the monorepo build pipeline
- The package uses dual ESM/CJS exports via tsup
- Follow Vercel style guide (configured via
@vercel/style-guide) - Be familiar with Module Federation, single-spa, and Next.js Multi-Zones
pnpm build- Build all packages using Turbopnpm test- Run unit tests for all packagespnpm lint- Run ESLint on all packagespnpm format- Format all files with Prettierpnpm typecheck- Run TypeScript type checkingpnpm checks- Run build, lint, test, and typecheck on all packages (run before submitting PRs)
When running commands for a specific application, do not cd into the directory. Run commands from the root. The above commands can be run for a particular package by using a filter option: pnpm checks -F <package name>. Use this.
Make sure that pnpm checks is successful for the entire repository when verifying a change.
pnpm dev:nextjs-app- Run the Next.js App Router examplepnpm dev:nextjs-pages- Run the Next.js Pages Router examplepnpm dev:react-router- Run the React Router examplepnpm dev:single-spa- Run the single-spa examplepnpm dev:sveltekit- Run the SvelteKit example
When testing a change, make sure that these dev commands all start up the server successfully. If the server is running and there are no errors after 30 seconds, consider that successful.
pnpm changeset- Create a changeset for releasingpnpm version-packages- Version packages based on changesets
The microfrontends configuration is defined in microfrontends.json (or .jsonc) files that live in each application. The schema is at packages/microfrontends/schema/schema.json.
Key configuration concepts:
- Applications: Named microfrontends that map to Vercel project names
- Routing: Path patterns that determine which microfrontend handles which routes
- Development: Local and fallback URLs for development
- Asset Prefix: Unique identifiers for static assets per microfrontend
- Flags: Feature flags that conditionally route requests to different microfrontends
-
Config Layer (
src/config/)microfrontends-config/- Configuration parsing and validationmicrofrontends/server/- Server-side configuration utilitiesoverrides/- Routing overrideswell-known/- Well-known endpoints for client-side
-
Next.js Integration (
src/next/)config/-withMicrofrontends()wrapper that transforms Next.js configmiddleware/- Routing middleware for Next.js that handles path matching and zone routing when using feature flagsclient/- Client-side utilities (Link component, prefetch)testing/- Testing utilities for Next.js microfrontends
-
Other Framework Support (
src/)sveltekit/- SvelteKit integrationvite/- Vite integration
-
CLI & Local Proxy (
src/bin/)local-proxy.ts- HTTP proxy for local development that routes requests between locally running microfrontends or falls back to productionindex.ts- CLI commands (microfrontends proxy,microfrontends port)
AGENTS.md and packages/microfrontends/README.md are copies of CLAUDE.md and README.md respectively, regenerated on pnpm install via the prepare script. Do not edit them directly — changes will be overwritten. Edit the source files instead:
- To update AI agent instructions: edit
CLAUDE.md - To update the README: edit the root
README.md(copied topackages/microfrontends/README.mdonpnpm install)