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
Copy file name to clipboardExpand all lines: packages/plugin-rsc/README.md
+56-50Lines changed: 56 additions & 50 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,10 +4,10 @@ This package provides [React Server Components](https://react.dev/reference/rsc/
4
4
5
5
## Features
6
6
7
-
-**Framework-less RSC experience**: The plugin implements [RSC conventions](https://react.dev/reference/rsc/server-components) and provides low level `react-server-dom` runtime API without framework-specific abstractions.
8
-
-**CSS support**: CSS is automatically code-split both at client and server components and they are injected upon rendering.
7
+
-**Framework-agnostic**: The plugin implements [RSC bundler features](https://react.dev/reference/rsc/server-components) and provides low level RSC runtime (`react-server-dom`) API without framework-specific abstractions.
8
+
-**Runtime-agnostic**: Built on [Vite environment API](https://vite.dev/guide/api-environment.html)and works with other runtimes (e.g., [`@cloudflare/vite-plugin`](https://github.com/cloudflare/workers-sdk/tree/main/packages/vite-plugin-cloudflare)).
9
9
-**HMR support**: Enables editing both client and server components without full page reloads.
10
-
-**Runtime agnostic**: Built on [Vite environment API](https://vite.dev/guide/api-environment.html)and works with other runtimes (e.g., [`@cloudflare/vite-plugin`](https://github.com/cloudflare/workers-sdk/tree/main/packages/vite-plugin-cloudflare)).
10
+
-**CSS support**: CSS is automatically code-split both at client and server components and they are injected upon rendering.
- This demonstrates how to integrate [experimental React Router RSC API](https://remix.run/blog/rsc-preview). React Router now provides [official RSC support](https://reactrouter.com/how-to/react-server-components), so it's recommended to follow React Router's official documentation for the latest integration.
26
-
-[`./examples/basic`](./examples/basic)
27
-
- This is mainly used for e2e testing and include various advanced RSC usages (e.g. `"use cache"` example).
28
-
-[`./examples/ssg`](./examples/ssg)
29
-
- Static site generation (SSG) example with MDX and client components for interactivity.
22
+
**Start here:**[`./examples/starter`](./examples/starter) - Recommended for understanding the plugin
23
+
24
+
- Provides an in-depth overview of API with inline comments to explain how they function within RSC-powered React application.
25
+
26
+
**Integration examples:**
27
+
28
+
-[`./examples/basic`](./examples/basic) - Advanced RSC features and testing
29
+
- This is mainly used for e2e testing and includes various advanced RSC usages (e.g. `"use cache"` example).
30
+
-[`./examples/ssg`](./examples/ssg) - Static site generation with MDX and client components for interactivity.
- Demonstrates how to integrate [experimental React Router RSC API](https://remix.run/blog/rsc-preview). React Router now provides [official RSC support](https://reactrouter.com/how-to/react-server-components), so it's recommended to follow React Router's official documentation for the latest integration.
30
33
31
34
## Basic Concepts
32
35
@@ -132,7 +135,7 @@ import * as ReactServer from '@vitejs/plugin-rsc/rsc' // re-export of react-serv
132
135
133
136
// the plugin assumes `rsc` entry having default export of request handler
- `createFromReadableStream`: RSC deserialization (RSC stream -> React VDOM). This is also available on rsc environment itself. For example, it allows saving serailized RSC and deserializing it for later use.
This provides a raw js code to execute a browser entry file specified by `environments.client.build.rollupOptions.input.index`. This is intended to be used with React DOM SSR API, such as [`renderToReadableStream`](https://react.dev/reference/react-dom/server/renderToReadableStream)
349
327
350
328
```js
351
-
import bootstrapScriptContent from 'virtual:vite-rsc/bootstrap-script-content'
-`createFromReadableStream`: RSC deserialization (RSC stream -> React VDOM). This is also available on rsc environment itself. For example, it allows saving serialized RSC and deserializing it for later use.
-`createFromFetch`: a robust way of `createFromReadableStream((await fetch("...")).body)`
423
+
-`encodeReply/setServerCallback`: server function related...
424
+
423
425
## High level API
424
426
425
427
> [!NOTE]
@@ -473,6 +475,10 @@ export function Page() {
473
475
}
474
476
```
475
477
478
+
## Canary and Experimental channel releases
479
+
480
+
See https://github.com/vitejs/vite-plugin-react/pull/524 for how to install the package for React [canary](https://react.dev/community/versioning-policy#canary-channel) and [experimental](https://react.dev/community/versioning-policy#all-release-channels) usages.
481
+
476
482
## Credits
477
483
478
484
This project builds on fundamental techniques and insights from pioneering Vite RSC implementations.
0 commit comments