|
2 | 2 | title: "Rendering Modes" |
3 | 3 | --- |
4 | 4 |
|
5 | | -SolidStart has 3 kinds of rendering modes: `sync`, `async`, and `stream`. |
6 | | -Let's talk about how each of them work and which one to pick. |
| 5 | +SolidStart has 3 kinds of rendering modes: |
7 | 6 |
|
8 | | -:::note |
9 | | -Default is **stream** and performance-wise should be preferred as a rule-of-thumb. |
10 | | -::: |
| 7 | +- `sync`: renders on server with `renderToString` and performs Client-Side Rendering (CSR) for asynchronous features. |
| 8 | +- `async`: renders on server with `renderToStringAsync`. Blocking the response until all asynchronous data fetching is resolved. |
| 9 | +- `stream` (default): renders on server with `renderToStream`. Streaming the response as soon as possible and continuing to fetch asynchronous data in the background, resolving the page as soon as possible and sending next chunks. |
11 | 10 |
|
12 | 11 | All modes have some degree of Server-Side Rendering, you may need to change them globally depending on your deployment provider. |
13 | | -And you may prefer to override them for better bot support and SEO. |
14 | | - |
15 | | -## Impacted Features |
16 | | - |
17 | | -| Feature | sync | async | stream | |
18 | | -| -------------------- | ----------- | --------------------------- | ----------------------- | |
19 | | -| Data fetching | Client-side | Server-side (blocking) | Server-side (streaming) | |
20 | | -| Suspense fallbacks | Yes | No | Yes | |
21 | | -| Time to first byte | Fast | Slower (waits for all data) | Faster | |
22 | | -| Total page load time | Slower | Fast (server fetches) | Faster (progressive) | |
23 | 12 |
|
24 | 13 | ### Sync Mode |
25 | 14 |
|
26 | 15 | Uses [`renderToString`](/reference/rendering/render-to-string) to render the page from Solid's core to render the page synchronously. |
27 | 16 | All async features are disabled and the page is rendered as soon as possible and sent to the client-side where data fetching will happen post-hydration. |
28 | 17 |
|
| 18 | +:::caution[Page Components] |
| 19 | +In SolidStart, all page components are lazy-loaded by default. This means that `renderToString` will SSR only until `app.tsx` and the route components will be rendered client-side. |
| 20 | +::: |
| 21 | + |
| 22 | +Asynchronous features will be directly impacted since rendering will mostly happen on the client-side. |
| 23 | + |
| 24 | +- Data-fetching: client-side only, first load will render Suspense fallbacks. |
| 25 | +- Time To First Byte (TTFB): fast since the server-side rendering is minimal. |
| 26 | +- Total page load time: slower since the client-side rendering is heavier. |
| 27 | + |
29 | 28 | ### Async Mode |
30 | 29 |
|
31 | 30 | Uses [`renderToStringAsync`](/reference/rendering/render-to-string-async) to render the page from Solid's core to render the page asynchronously. |
32 | 31 | All Suspense boundaries are resolved and rendered before being sent to the client-side. |
33 | 32 |
|
| 33 | +:::tip[SEO and Bot Support] |
34 | 34 | No suspense fallbacks are shown in the browser, which makes this mode ideal for SEO optimizations and bot support. |
| 35 | +::: |
| 36 | + |
| 37 | +Asynchronous features will happen in the Server-Side during first render. |
| 38 | + |
| 39 | +- **Data-fetching**: first render will be similar to sync mode, but data fetching will still happen in the background and responses will be streamed in chunks as available. |
| 40 | +- **Time To First Byte (TTFB)**: slower since the server-side rendering is heavier. |
| 41 | +- **Total page load time**: faster than sync mode since the server-side tends to be faster than the client-side. |
35 | 42 |
|
36 | | -### Stream Mode |
| 43 | +### Stream Mode (default) |
37 | 44 |
|
38 | 45 | Uses [`renderToStream`](/reference/rendering/render-to-stream) to render the page from Solid's core to render the page streaming. |
39 | 46 | Leveraging [TransformableStream](https://developer.mozilla.org/en-US/docs/Web/API/TransformStream) to progressively send the HTML to the client-side. |
40 | 47 |
|
41 | | -This mode is ideal for performance and future-friendly apps. |
| 48 | +:::tip[Performance and Future-Friendly Apps] |
| 49 | +This mode is ideal for performance and future-friendly apps. It provides best perceived performance and consumes less memory and CPU from the client-side. |
| 50 | +::: |
| 51 | + |
| 52 | +Asynchronous features will happen in the Server-Side during first render. |
| 53 | + |
| 54 | +- **Data-fetching**: server-side only, data fetching will happen in the background and the page will be rendered as soon as possible. |
| 55 | +- **Time To First Byte (TTFB)**: faster since the server-side rendering is lighter. |
| 56 | +- **Total page load time**: faster since the server-side tends to be faster than the client-side. |
42 | 57 |
|
43 | 58 | ## Global Configuration |
44 | 59 |
|
|
0 commit comments