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
| Time to first byte | Fast | Slower (waits for all data) | Faster |
22
+
| Total page load time | Slower | Fast (server fetches) | Faster (progressive) |
23
+
24
+
### Sync Mode
25
+
26
+
Uses [`renderToString`](/reference/rendering/render-to-string) to render the page from Solid's core to render the page synchronously.
27
+
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
+
29
+
### Async Mode
30
+
31
+
Uses [`renderToStringAsync`](/reference/rendering/render-to-string-async) to render the page from Solid's core to render the page asynchronously.
32
+
All Suspense boundares are resolved and rendered before being sent to the client-side.
33
+
34
+
No suspense fallbacks are shown in the browser, which makes this mode ideal for SEO optimizations and bot support.
35
+
36
+
### Stream Mode
37
+
38
+
Uses [`renderToStream`](/reference/rendering/render-to-stream) to render the page from Solid's core to render the page streaming.
39
+
Leveraging [TransformableStream](https://developer.mozilla.org/en-US/docs/Web/API/TransformStream) to progressively send the HTML to the client-side.
40
+
41
+
This mode is ideal for performance and future-friendly apps. .
42
+
43
+
## Global Configuration
44
+
45
+
The modes can be defined app-wide via the configuration file or via the [`entry-server.tsx`](/solid-start/reference/entrypoints/entry-server) file.
The value in [`entry-server.tsx`](/solid-start/reference/entrypoints/entry-server) overrides the value in [`app.config.ts`](/solid-start/reference/entrypoints/app-config).
The optional secondary parameter in [`createHandler`](/solid-start/reference/server/create-handler) can be an object or a function that receives the `RequestEvent` and returns an object with the mode to use for the route.
| vite |`ViteConfig` or `({ router })=>ViteConfig`||[Vite config object](https://vitejs.dev/config/shared-options.html). Can be configured for each `router` which has the string value "server", "client" or "server-function"` |
| vite |`ViteConfig` or `({ router })=>ViteConfig`||[Vite config object](https://vitejs.dev/config/shared-options.html). Can be configured for each `router` which has the string value "server", "client" or "server-function"` |
Copy file name to clipboardExpand all lines: src/routes/solid-start/reference/entrypoints/entry-server.mdx
+5-4Lines changed: 5 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,11 +2,12 @@
2
2
title: entry-server.tsx
3
3
---
4
4
5
-
`entry-server.tsx` is where an application starts on the server.
5
+
This is where application is rendered on the server.
6
6
This happens by `entry-server.tsx` providing a document component to [`<StartServer>`](/solid-start/reference/server/start-server) and passing it into [`createHandler`](/solid-start/reference/server/create-handler) for server side rendering.
7
-
A typical `entry-server.tsx` for a new project looks like this:
8
7
9
-
```tsx
8
+
Every SolidStart app must have an `entry-server.tsx` file, the most basic usage looks about the following example:
For setting different SSR modes (sync | async | stream), see [`createHandler`](/solid-start/reference/server/create-handler).
33
+
To take full advantage of the `entry-server.tsx` file, check the [`createHandler` docs](/solid-start/reference/server/create-handler) and the [Rendering Modes](/solid-start/building-your-application/rendering-modes) page.
Copy file name to clipboardExpand all lines: src/routes/solid-start/reference/server/create-handler.mdx
+22-14Lines changed: 22 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,28 +3,36 @@ title: createHandler
3
3
---
4
4
5
5
The `createHandler` is used to start the server in [`entry-server.tsx`](/solid-start/reference/entrypoints/entry-server).
6
-
It takes a function that returns a static document (often created with [`<StartServer>`](/solid-start/reference/server/start-server)), and serves it using one of the three function for server side rendering (SSR):
6
+
It takes a function that returns a static document (often created with [`<StartServer>`](/solid-start/reference/server/start-server)), renders, and serves it.
To fully understand how to leverage different rendering modes, please refer to the [Rendering Modes](/solid-start/building-your-application/rendering-modes) page.
10
+
:::
11
11
12
-
The SSR mode can be configured through the `mode` property on the options object:
12
+
A `createHandler` is essential to every SolidStart app.
13
+
To fallback the rendering mode to the [`app.config.ts`](/solid-start/reference/entrypoints/app-config-ts) definition (or the default "stream" mode), you can use the `createHandler` without any options.
It is also possible to [override the rendering mode for a specific route](/solid-start/building-your-application/rendering-modes#per-route-configuration).
0 commit comments