SSR
Rendering on the server with Solid 2 (Vite's SSR and @solidjs/vite-plugin, what the server renders, hydration, running in production)
The Solid version renders without errors on the server (SSR) and hands the table over to the browser through hydration. For the React version (Next.js), see Next.js and SSR.
Setup
SolidStart currently supports only Solid 1. With Solid 2, use Vite's SSR and @solidjs/vite-plugin (ssr: true): the server uses renderToString or renderToStream with generateHydrationScript, and the client uses hydrate (@solidjs/router 2 also needs createRequestEvent from @solidjs/web and provideRequestEvent from @solidjs/web/storage).
// entry-server.tsx
import { generateHydrationScript, renderToString } from '@solidjs/web'
import { App } from './App'
export function render() {
return { head: generateHydrationScript(), html: renderToString(() => <App />) }
}// entry-client.tsx
import { hydrate } from '@solidjs/web'
import { App } from './App'
hydrate(() => <App />, document.getElementById('app')!)What the server renders
- The server renders the same things as the React version (the skeleton, the row numbers and pinned column cells of the first rows, the counts and the totals). Columns that aren't pinned need the grid's width, so as in the React version they render in the browser.
- The server's rows are a display-only copy. After hydration, within the same task, they are replaced with rows computed in the browser. Even if the server and the browser differ in time zone or in what "today" is (date conditions, Date values), the server's rows don't stay on the page.
- Solid's hydration doesn't fix text that turns out different on the client, so the server HTML contains a hidden skeleton with the rows used for hydration left empty, followed by the copy (the copy is removed after hydration; the React version re-renders mismatches on the client). Only the copy has
.ssg-root, so the server HTML has one.ssg-root, as in the React version (the skeleton gets it after hydration; in 1.4.0 both had it). - Initial sorting, filtering and column widths (
initialState) take effect from the server render. To set the initial state from the URL, read the URL on the server and pass it toinitialState(Saving and restoring state).
Running in production
Start the production server with NODE_ENV=production (or add define: { 'process.env.NODE_ENV': JSON.stringify('production') } to the SSR build). Without it, the server also renders development-only parts, and hydration can't take over the grid.
Notes for Solid
Differences from the React version (ref, when render functions run, /ai, speed), signals and stores, when writes take effect, actions, async rows, testing, picking the features you ship, versions
Loading the CSS and coexistence
Loading style.css / style.layer.css, and coexisting with Tailwind CSS, HeroUI, Mantine, StyleX, Astryx and UI SDK (the same for React and Solid)