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.
Then 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
name: Application name. Falls back topackage.jsonname (without scope) or "react-server-app".
Environment Variables
The generated server supports the following environment variables at runtime:
PORT: Server port (default:3000)HOST: Server hostname (default:0.0.0.0)ORIGIN: Override the origin URL for the server
The Deno adapter uses an edge build mode, bundling your entire server into a single file. At build time, it:
- Bundles your server code into
.deno/server/.react-server/server/edge.mjs - Copies all static assets into
.deno/static/ - Generates a
start.mjsscript with a build-time static route map that serves static files usingDeno.readFile()with proper MIME type detection - Creates a
deno.jsonwith 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 directly:
deno run --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:
- Bare metal / VPS: Copy the
.deno/directory and rundeno task start - Deno Deploy: Deploy using
deployctl— see the Deno Deploy docs - Docker: Use the official Deno Docker image
- Fly.io: Deploy with
flyctlusing a Dockerfile - Railway, Render: Point the start command to
deno run --allow-net --allow-read --allow-env --allow-sys .deno/start.mjs
Example Dockerfile
FROM denoland/deno:latest
WORKDIR /app
COPY .deno/ .
EXPOSE 3000
CMD ["deno", "task", "start"]