DeployEdit this page.md

Deno

To deploy as a standalone Deno server, use the built-in deno adapter. This adapter uses Deno's native Deno.serve() API with edge-compatible fetch handlers and build-time static route mapping.

You need Deno installed on your system:

curl -fsSL https://deno.land/install.sh | sh

No additional packages are needed - the adapter is built into @lazarv/react-server.

When you run a production build with Deno, the deno adapter is automatically detected and used — no configuration is needed. If you want to be explicit or need to pass options, you can add the adapter to your react-server.config.mjs file:

export default { adapter: "deno", };

You can customize the adapter by passing options:

export default { adapter: [ "deno", { name: "my-app", // Application name (used in generated deno.json) }, ], };

Configuration Options

Environment Variables

The generated server supports the following environment variables at runtime:

The Deno adapter uses an edge build mode, bundling your entire server into a single file. At build time, it:

  1. Bundles your server code into .deno/server/.react-server/server/edge.mjs
  2. Copies all static assets into .deno/static/
  3. Generates a start.mjs script with a build-time static route map that serves static files using Deno.readFile() with proper MIME type detection
  4. Creates a deno.json with a start task for easy deployment

Static files (HTML, CSS, JS, images, etc.) are resolved from the build-time route map and served directly without going through the server handler.

Build your application using the react-server CLI:

pnpm react-server build [root]

This produces a .deno/ directory with the following structure:

.deno/ ├── start.mjs # Entry point with static route map ├── deno.json # Deno configuration with start task ├── static/ # All static assets │ ├── assets/ # Hashed build assets (CSS, JS) │ ├── client/ # Client-side bundles │ └── ... # Public files, pre-rendered HTML └── server/ └── .react-server/ └── server/ └── edge.mjs # Bundled server

Start the production server using the CLI:

deno run -A npm:@lazarv/react-server start

Or run it directly without the runtime installed:

deno run --config .deno/deno.json --allow-net --allow-read --allow-env --allow-sys .deno/start.mjs

Or use the --deploy flag to build and immediately start:

pnpm react-server build [root] --deploy

You can also use the generated deno.json task:

cd .deno deno task start

Since the Deno adapter produces a self-contained server, you can deploy it anywhere Deno runs:

Example Dockerfile

FROM denoland/deno:latest WORKDIR /app COPY .deno/ . EXPOSE 3000 CMD ["deno", "task", "start"]