Framework β†’Edit this page

CLI

The react-server CLI is the main tool for developing and deploying your @lazarv/react-server applications. It provides a set of commands to help you build, run, and deploy your app.

To check out the available commands, run:

pnpm react-server --help

You need to always define the entrypoint of your app as the first argument of the react-server command. Only exception is when you use the file-system based router as it will define the entrypoint for you.

The [root] of your app has to export default a React Server Component. This is the entrypoint of your app and this will be rendered on the server side for every request.

You can also use a hash fragment in the entrypoint to specify a specific export. For example, if you have an entrypoint at ./index.jsx and you want to use the App export, you can use ./index.jsx#App.

If your entrypoint is at ./App.jsx, you can start the development server with:

pnpm react-server ./App.jsx

To start the development server, you can use the following options:

The host to listen on. Default is localhost.

The port to listen on. Default is 3000.

Use HTTPS protocol. Default is false.

When you want to use HTTPS for your development server. You need to specify your HTTPS configuration in your react-server.config.mjs or vite.config.mjs file. See details in the Vite documentation at server.https.

Open browser on server start. Default is false. Opens your app in the default browser.

Enable CORS. Default is false.

This is useful when you want to allow cross-origin requests. If you need more detailed CORS configuration, you can define the CORS configuration in your react-server.config.mjs or vite.config.mjs file. See details in the Vite documentation at server.cors.

Force optimize deps. Default is false. This is equal to vite --force. It will force the optimization of dependencies and clears the Vite cache.

Watch for config changes. Default is true. To disable watching for config changes, use --no-watch.

Clear screen on server start. Default is false. If you want to start with a clean terminal screen.

Disable color output. Default is false. This is useful for CI/CD environments.

Evaluate the server entrypoint from the argument, like node -e. You can also use stdin as the entrypoint. This type of entrypoint becomes a virtualized entrypoint and is not written to the file system.

Display version number. Output will also include your machine's architecture and node.js version.

Output directory for the build. Default is .react-server.

Name of the server. Default is react-server. Used for logging.

Minify your build. Default is true.

You don't need to minify your app if you only use React Server Components and you are not using any client components, like in the Todo example. If you want to disable minification of client component code, use --no-minify.

Generate source maps for production builds. Default is false.

Accepted values: true, inline, hidden, server, or server-inline.

ValueDescription
trueGenerates .map files for both server and client bundles
inlineEmbeds source maps inline in the output files
hiddenGenerates .map files without sourceMappingURL comments
serverGenerates .map files only for server bundles
server-inlineEmbeds source maps inline only in server bundles

When source maps are enabled, server-side error stack traces in production are automatically rewritten to show original source file locations using source-map-support. If NODE_OPTIONS='--enable-source-maps' is already set, the source-map-support package is skipped to avoid conflicts.

Use --sourcemap=server or --sourcemap=server-inline to keep your source code private from browser devtools while still getting mapped stack traces on the server.

You can also configure this in react-server.config.mjs:

export default {
  sourcemap: true, // or "inline", "hidden", "server", "server-inline"
};

Note: When deploying with adapters, source maps are automatically handled per platform:

  • Vercel: .map files are included in the function bundle and NODE_OPTIONS='--enable-source-maps' is set.
  • Cloudflare: upload_source_maps is enabled in wrangler.toml for dashboard and wrangler tail support.
  • Netlify: .map files are deployed alongside functions. Deno-based edge functions pick them up natively.

On edge runtimes, the source-map-support package is skipped since these platforms handle source maps at the infrastructure level.

See more details in the Vite documentation at build.sourcemap.

Disable color output. Default is false. This is useful for CI/CD environments.

Static export. Default is false.

You can export your app as static HTML pages. You can define the routes to export in your react-server.config.mjs file. See more details at Static generation.

Enable compression. Default is false.

You can enable compression if you want to compress your static build. Compression is not enabled by default for static builds. Gzip and Brotli compression is used when compression is enabled. The production mode server serves these compressed files by default when the compressed static files are present.

Deploy using adapter. Default is false.

If you use an adapter in your react-server.config.mjs file, the adapter will pre-build your app for deployment and when you use this argument, the adapter will also deploy your app at the end of the build process.

Evaluate the server entrypoint from the argument, like node -e. You can also use stdin as the entrypoint. This type of entrypoint becomes a virtualized entrypoint and is not written to the file system.

Output directory for the build. Default is .react-server.

Set the mode for the build. Default is production.

Enable edge build mode. Default is false. Builds your app for edge runtime environments.

Suppress build output. Default is false.

This option suppresses all build output from the bundler. Useful for CI/CD environments or when running builds programmatically where you don't want verbose output.

Verbose build output. Default is false. Enables detailed build logs from the bundler.

host, port, https and cors are the same as in the development server options.

Specify the origin part of the URL to a constant value. Same as using the ORIGIN environment variable.

Trust X-Forwarded-* headers.

Runs the build command before starting the server using the provided entrypoint.

Output directory for the build. Default is .react-server. You need to specify this option if you used a different output directory in the build command than the default.