Reference

CLI

The mreact-router CLI is the operational entrypoint for local development, production builds, serving Node output, and packaging adapter artifacts. Use command-level help when you need the exact option list for the installed version.

When to use this page

Use this page when you need to choose the right CLI command, map an npm script to a build target, enable request logging, or create deployment artifacts from an existing .mreact build.

Commands

  • mreact-router dev starts the Vite-backed development server. It is the default when no command is provided.
  • mreact-router build --target=node builds Node server output and client assets into .mreact.
  • mreact-router build --target=cloudflare builds Cloudflare-compatible output.
  • mreact-router build --target=aws-lambda builds AWS Lambda-compatible output.
  • mreact-router build --target=all writes every supported target in one build.
  • mreact-router start serves the built Node target.
  • mreact-router package aws-lambda creates a minimal AWS Lambda package directory from existing build output.
  • mreact-router package cloudflare-pages creates a Cloudflare Pages advanced-mode artifact with _worker.js.
mreact-router dev --host 0.0.0.0 --port 3001 --log requests
mreact-router build --target=node --client-source-maps=hidden
mreact-router build --target=aws-lambda
mreact-router package aws-lambda --from .mreact --out .lambda

Options to know first

  • --target=node|cloudflare|aws-lambda|all controls which production artifact is built.
  • --client-source-maps=none|hidden controls production browser source maps. Use hidden when you upload maps to Sentry or another error pipeline without publishing source map comments to browsers.
  • mreact-router dev reads --host and --port.
  • mreact-router start reads --host, --host-policy, and --allowed-hosts. Set PORT when you need a non-default start-server port.
  • --log requests enables compact request logs. MREACT_ROUTER_LOG=requests enables the same mode from the environment.
  • --from, --out, --handler, and --skip-runtime-dependency-check are packaging options used after a build.

Package scripts

Keep application scripts explicit about the target they produce. That makes CI logs and deployment jobs easier to read.

{
  "scripts": {
    "dev": "mreact-router dev",
    "build": "mreact-router build --target=node",
    "build:cloudflare": "mreact-router build --target=cloudflare",
    "build:lambda": "mreact-router build --target=aws-lambda",
    "start": "mreact-router start"
  }
}

API reference: buildApp(), startServer(), packageAwsLambdaArtifact(), and packageCloudflarePagesArtifact().