Multitenant

dev, check, print

Local proxy, validation, and config inspection.

multitenant dev — local proxy

Maps tenant hostnames to your app's dev server and injects headers (x-tenant-key, x-market-key, x-tenant-env, optional flags JSON).

npx @multitenant/cli dev [options]
OptionDefaultDescription
--configauto-discoverPath to tenants.config.json
--cwdprocess.cwd()Working directory
-p / --port3100Proxy listen port
-t / --targethttp://localhost:3000Your app URL
--run-devoffSpawn npm/pnpm/yarn run dev`
--envlocallocal | development | staging | production

Behaviour: load + validate config → build registry → proxy → forward Host resolution as headers → watch config file and hot-reload registry.

Examples

npx @multitenant/cli dev --target http://localhost:3000 --port 3100
npx @multitenant/cli dev --run-dev --port 3100

Then open e.g. http://us.localhost:3100 — use a hostname from your config’s domains.local (first label is often the tenant subdomain), not http://localhost:3100. localhost is not a tenant host, so the proxy cannot resolve a tenant (it responds with a short HTML hint listing example hosts).

Browsing http://us.localhost:3000 with next dev on 3000 is also valid: no proxy, but Host still matches domains.local.


multitenant check

Validates tenants.config.json and exits 0 or 1 with the same errors validateTenantsConfig throws in code.

npx @multitenant/cli check

Use in CI next to your tests.


multitenant print

Prints a normalized view of the config (tenants, domains per environment) — useful for debugging large files. Run multitenant print --help for flags.

On this page