Skip to content

Commit f9df9d1

Browse files
committed
chore: tweak
1 parent e712d08 commit f9df9d1

File tree

1 file changed

+39
-35
lines changed

1 file changed

+39
-35
lines changed

packages/plugin-rsc/README.md

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ This package provides [React Server Components](https://react.dev/reference/rsc/
44

55
## Features
66

7-
- **Framework-agnostic**: 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 `react-server-dom` runtime 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)).
99
- **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.
1111

1212
## Getting Started
1313

@@ -25,11 +25,11 @@ npx degit vitejs/vite-plugin-react/packages/plugin-rsc/examples/starter my-app
2525

2626
**Integration examples:**
2727

28-
- [`./examples/react-router`](./examples/react-router) - React Router RSC integration
29-
- 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-
- [`./examples/ssg`](./examples/ssg) - Static site generation with MDX and client components for interactivity.
3128
- [`./examples/basic`](./examples/basic) - Advanced RSC features and testing
3229
- This is mainly used for e2e testing and include various advanced RSC usages (e.g. `"use cache"` example).
30+
- [`./examples/ssg`](./examples/ssg) - Static site generation with MDX and client components for interactivity.
31+
- [`./examples/react-router`](./examples/react-router) - React Router RSC integration
32+
- 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.
3333

3434
## Basic Concepts
3535

@@ -215,7 +215,7 @@ main();
215215
216216
The plugin provides an additional helper for multi environment interaction.
217217
218-
### available on `rsc` or `ssr` environment
218+
### Available on `rsc` or `ssr` environment
219219
220220
#### `import.meta.viteRsc.loadModule`
221221
@@ -238,7 +238,7 @@ ssrModule.renderHTML(...);
238238
export function renderHTML(...) {}
239239
```
240240
241-
### available on `rsc` environment
241+
### Available on `rsc` environment
242242
243243
#### `import.meta.viteRsc.loadCss`
244244
@@ -319,7 +319,7 @@ function __Page(props) {
319319
export { __Page as Page }
320320
```
321321

322-
### available on `ssr` environment
322+
### Available on `ssr` environment
323323

324324
#### `import.meta.viteRsc.loadBootstrapScriptContent("index")`
325325

@@ -336,7 +336,7 @@ const htmlStream = await renderToReadableStream(reactNode, {
336336
})
337337
```
338338

339-
### available on `client` environment
339+
### Available on `client` environment
340340

341341
#### `rsc:update` event
342342

@@ -354,31 +354,6 @@ import.meta.hot.on('rsc:update', async () => {
354354
})
355355
```
356356

357-
## `react-server-dom` API
358-
359-
### `@vitejs/plugin-rsc/rsc`
360-
361-
This module re-exports RSC runtime API provided by `react-server-dom/server.edge` and `react-server-dom/client.edge` such as:
362-
363-
- `renderToReadableStream`: RSC serialization (React VDOM -> RSC stream)
364-
- `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.
365-
- `decodeAction/decodeReply/decodeFormState/loadServerAction/createTemporaryReferenceSet`
366-
- `encodeReply/createClientTemporaryReferenceSet`
367-
368-
### `@vitejs/plugin-rsc/ssr`
369-
370-
This module re-exports RSC runtime API provided by `react-server-dom/client.edge`
371-
372-
- `createFromReadableStream`: RSC deserialization (RSC stream -> React VDOM)
373-
374-
### `@vitejs/plugin-rsc/browser`
375-
376-
This module re-exports RSC runtime API provided by `react-server-dom/client.browser`
377-
378-
- `createFromReadableStream`: RSC deserialization (RSC stream -> React VDOM)
379-
- `createFromFetch`: a robust way of `createFromReadableStream((await fetch("...")).body)`
380-
- `encodeReply/setServerCallback`: server function related...
381-
382357
## Plugin API
383358

384359
### `@vitejs/plugin-rsc`
@@ -423,6 +398,31 @@ export default defineConfig({
423398
})
424399
```
425400

401+
## RSC runtime (react-server-dom) API
402+
403+
### `@vitejs/plugin-rsc/rsc`
404+
405+
This module re-exports RSC runtime API provided by `react-server-dom/server.edge` and `react-server-dom/client.edge` such as:
406+
407+
- `renderToReadableStream`: RSC serialization (React VDOM -> RSC stream)
408+
- `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.
409+
- `decodeAction/decodeReply/decodeFormState/loadServerAction/createTemporaryReferenceSet`
410+
- `encodeReply/createClientTemporaryReferenceSet`
411+
412+
### `@vitejs/plugin-rsc/ssr`
413+
414+
This module re-exports RSC runtime API provided by `react-server-dom/client.edge`
415+
416+
- `createFromReadableStream`: RSC deserialization (RSC stream -> React VDOM)
417+
418+
### `@vitejs/plugin-rsc/browser`
419+
420+
This module re-exports RSC runtime API provided by `react-server-dom/client.browser`
421+
422+
- `createFromReadableStream`: RSC deserialization (RSC stream -> React VDOM)
423+
- `createFromFetch`: a robust way of `createFromReadableStream((await fetch("...")).body)`
424+
- `encodeReply/setServerCallback`: server function related...
425+
426426
## High level API
427427

428428
> [!NOTE]
@@ -476,6 +476,10 @@ export function Page() {
476476
}
477477
```
478478

479+
## Canary/Experimental channel releases
480+
481+
TODO
482+
479483
## Credits
480484

481485
This project builds on fundamental techniques and insights from pioneering Vite RSC implementations.

0 commit comments

Comments
 (0)