Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarred-Sumner committed May 5, 2024
1 parent 72bc258 commit 9bfeb0a
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion docs/guides/ecosystem/ssr-react.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
name: Server-side render (SSR) a React component
---

To get started, install the canary version of `react` & `react-dom`:

```sh
# Any package manager can be used
$ bun add react@canary react-dom@canary
```

---

To render a React component to an HTML stream server-side (SSR):

```tsx
Expand Down Expand Up @@ -39,4 +48,8 @@ Bun.serve({

---

React `18.3` and later includes an [SSR optimization](https://github.com/facebook/react/pull/25597) that takes advantage of Bun's "direct" `ReadableStream` implementation.
React `19` and later includes an [SSR optimization](https://github.com/facebook/react/pull/25597) that takes advantage of Bun's "direct" `ReadableStream` implementation.

---

If you run into an error like `export named 'renderToReadableStream' not found`, please make sure to install the canary version of `react` & `react-dom`, or import from `react-dom/server.browser` instead of `react-dom/server`. See [facebook/react#28941](https://github.com/facebook/react/issues/28941) for more information.

0 comments on commit 9bfeb0a

Please sign in to comment.