You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add first-class Bun and Deno runtime support (#309)
## First-class Bun & Deno runtime support
Until now, `@lazarv/react-server` has been a Node.js-first framework
with experimental adapter-level support for alternative runtimes. This
PR promotes **Bun** and **Deno** to fully supported, first-class
runtimes — from project scaffolding all the way through development,
production builds, and deployment.
### What changes for users
**Zero-config runtime detection** — When you run `react-server build` or
`react-server start` under Bun or Deno, the framework now automatically
detects the runtime and applies the correct adapter. No manual `adapter:
"bun"` or `adapter: "deno"` configuration is needed anymore (though
explicit overrides and `--no-adapter` still work).
**Scaffolding just works** — `create-react-server` now detects the
runtime you're using at project creation time and automatically
configures `package.json` scripts accordingly:
- **Bun** projects get `bun --bun react-server ...` scripts and
`trustedDependencies`
- **Deno** projects get `deno run -A npm:@lazarv/react-server ...`
scripts and a `deno.json` with `nodeModulesDir: "manual"` + `byonm`
- **Node.js** projects continue to work exactly as before
**Simplified production start** — Instead of requiring users to manually
run `.bun/start.mjs` or `.deno/start.mjs`, the standard `react-server
start` command now handles everything, including import map generation
for Deno and proper process spawning for both runtimes.
### What changes under the hood
- **Runtime-aware module loading** — New loader plugins
(`lib/loader/bun.mjs` and `lib/loader/deno.mjs`) handle the differences
in how each runtime resolves `@lazarv/react-server/dist/...` specifiers,
manifest files, and prebuilt configs during production serving.
- **Dev server rendering for Deno** — Since Deno doesn't support Node.js
`worker_threads`, a new process-based rendering pipeline
(`render-process.mjs`, `render-process-channel.mjs`,
`render-process-spawn.mjs`) communicates over stdio, replacing the
worker thread approach while keeping the same external API.
- **Improved `sys.mjs` process shim** — The Deno process polyfill is now
more robust (adds `on`/`off`/`once`/`stdout`/`stderr` stubs) and no
longer overwrites the real `process` global when Deno's Node compat
layer already provides one.
### New examples
- **`examples/bun/`** — A complete Bun example with SSR, client-side
hydration, and interactive counter
- **`examples/deno/`** — A complete Deno example with the same feature
set plus `react-server.deno.json` configuration
### Testing
- **Docker-based integration tests** for `create-react-server` covering
Node.js, Bun, and Deno — each runtime is tested in an isolated container
to verify that scaffolded projects build and start correctly.
- **Vitest snapshot tests** verifying the generated project structure
for each runtime/preset combination.
- **New CI workflow** (`.github/workflows/create-react-server.yml`) runs
these tests automatically on push and PR.
### Documentation
Updated the getting started guide and deployment docs (English and
Japanese) to reflect that Deno is now fully supported, remove the "not
supported yet" notices, and document automatic adapter detection along
with simplified deployment commands.
Copy file name to clipboardExpand all lines: docs/src/pages/en/(pages)/deploy/adapters.mdx
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,6 +26,8 @@ You can use adapters to configure your app for different deployment environments
26
26
27
27
Add `adapter` entry to your `react-server.config.mjs` file. You can specify the name of a built-in adapter (`vercel`, `netlify`, `cloudflare`, `bun`, or `deno`) as a string, or use an external adapter package.
28
28
29
+
> **Note:** When running a production build with **Bun** or **Deno**, the corresponding adapter is automatically detected and used without any configuration. You can override this with an explicit `adapter` setting in your config or via `--adapter <name>` on the CLI. Use `--no-adapter` to disable auto-detection.
No additional packages are needed - the adapter is built into `@lazarv/react-server`.
24
24
25
-
Then add the adapter to your `react-server.config.mjs` file:
25
+
When you run a production build with Bun, the `bun` 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:
26
26
27
27
```mjs
28
28
exportdefault {
@@ -102,10 +102,16 @@ This produces a `.bun/` directory with the following structure:
102
102
## Deploy
103
103
</Link>
104
104
105
-
Start the production server directly:
105
+
Start the production server using the CLI:
106
106
107
107
```sh
108
-
bun .bun/start.mjs
108
+
bun --bun react-server start
109
+
```
110
+
111
+
Or run it directly without the framework installed:
112
+
113
+
```sh
114
+
bun --bun .bun/start.mjs
109
115
```
110
116
111
117
Or use the `--deploy` flag to build and immediately start:
Copy file name to clipboardExpand all lines: docs/src/pages/en/(pages)/deploy/deno.mdx
+9-3Lines changed: 9 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@ curl -fsSL https://deno.land/install.sh | sh
22
22
23
23
No additional packages are needed - the adapter is built into `@lazarv/react-server`.
24
24
25
-
Then add the adapter to your `react-server.config.mjs` file:
25
+
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:
26
26
27
27
```mjs
28
28
exportdefault {
@@ -102,10 +102,16 @@ This produces a `.deno/` directory with the following structure:
102
102
## Deploy
103
103
</Link>
104
104
105
-
Start the production server directly:
105
+
Start the production server using the CLI:
106
106
107
107
```sh
108
-
deno run --allow-net --allow-read --allow-env --allow-sys .deno/start.mjs
108
+
deno run -A npm:@lazarv/react-server start
109
+
```
110
+
111
+
Or run it directly without the framework installed:
112
+
113
+
```sh
114
+
deno run --config .deno/deno.json --allow-net --allow-read --allow-env --allow-sys .deno/start.mjs
109
115
```
110
116
111
117
Or use the `--deploy` flag to build and immediately start:
> **Note:** Deno is not supported yet. Please check back later for updates.
119
-
119
+
```sh
120
+
deno run -A npm:@lazarv/react-server ./App.jsx
121
+
```
120
122
</Tab>
121
123
122
124
</Tabs>
@@ -127,7 +129,7 @@ bun --bun react-server ./App.jsx
127
129
## Build
128
130
</Link>
129
131
130
-
After you have developed your application, you can build it for production. This will create a `.react-server` folder with all files needed to run your application in production mode.
132
+
After you have developed your application, you can build it for production. This will create a `.react-server` folder with all files needed to run your application in production mode. When using Bun or Deno, the corresponding adapter is automatically detected and used, producing a self-contained bundle in `.bun/` or `.deno/`. You can override the auto-detected adapter with `--adapter <name>` or disable it with `--no-adapter`.
131
133
132
134
<Tabsname="build">
133
135
@@ -156,9 +158,9 @@ bun --bun react-server build ./App.jsx
> **Note:** Deno is not supported yet. Please check back later for updates.
161
-
161
+
```sh
162
+
deno run -A npm:@lazarv/react-server build ./App.jsx
163
+
```
162
164
</Tab>
163
165
164
166
</Tabs>
@@ -167,7 +169,7 @@ bun --bun react-server build ./App.jsx
167
169
## Production mode
168
170
</Link>
169
171
170
-
To start your application in production, just use the `start` command. This will start your application in production mode.
172
+
To start your application in production, just use the `start` command. This will start your application in production mode. When using Bun or Deno, the start command runs the adapter's generated entry point directly.
171
173
172
174
<Tabsname="production-mode">
173
175
@@ -196,14 +198,14 @@ bun --bun react-server start
> **Note:** Deno is not supported yet. Please check back later for updates.
201
-
201
+
```sh
202
+
deno run -A npm:@lazarv/react-server start
203
+
```
202
204
</Tab>
203
205
204
206
</Tabs>
205
207
206
-
> **Note:** if you don't want to install the `@lazarv/react-server` package and you just want to try out something quickly, you can use `npx` to run the `react-server` CLI. This way, it's not required to install anything else if you use JavaScript. It's enough to have a `.jsx` file with a React Server Component exported as default to run your application. Just run `npx @lazarv/react-server ./App.jsx` to start your application in development mode. When using Bun, you can use `bunx --bun @lazarv/react-server` to run the `react-server` CLI.
208
+
> **Note:** if you don't want to install the `@lazarv/react-server` package and you just want to try out something quickly, you can use `npx` to run the `react-server` CLI. This way, it's not required to install anything else if you use JavaScript. It's enough to have a `.jsx` file with a React Server Component exported as default to run your application. Just run `npx @lazarv/react-server ./App.jsx` to start your application in development mode. When using Bun, you can use `bunx --bun @lazarv/react-server` to run the `react-server` CLI. When using Deno, you can use `deno run -A npm:@lazarv/react-server ./App.jsx` to start a development server.
0 commit comments