# Application Design: prerendering Details: [components.md](components.md), [component-methods.md](component-methods.md), [services.md](services.md), [component-dependency.md](component-dependency.md). ## Spike Evidence Tested in a throwaway app outside the repository: `@tanstack/react-start` 1.169.4 and `@tanstack/react-router` 1.170.46 with Chakra, in Chrome, against a static test server with the production `script-src`. The app had three simple pages, so the real components are still untested. | Test | Result | |---|---| | Inline scripts under the production CSP | Blocked; page error; content disappears | | Inline scripts moved to `/assets` | Hydrates; button and client-side link work; no CSP violations | | `autoSubfolderIndex: false`, served as `/over-mij.html` for `/over-mij` | Status 200, no redirect, no errors | | 404 page rendered from a route giving status 404 | Build fails: Start rejects a non-OK response | | Separate `/404` route, served for unknown URLs | Status 404 and correct URL, but React hydration error #418 | | Start's SPA shell as the 404 page | Rejected: `index.html` is not generated, and error #418 remains | | Catch-all `$` route, prerendered to `404.html`, URL-dependent output after hydration | Status 404, correct URL, no hydration error | | `/?pakket=gezin` reading the search value in the first render | Correct value, but hydration error #418 | | Same, with the value applied after hydration | Correct value, no error | ## Decisions | # | Decision | Reason | Rejected | |---|---|---|---| | D1 | Prerender with Start, `autoSubfolderIndex: false`, all pages listed from `sitePages.ts` | URLs stay without a slash; a page cannot be forgotten through crawling alone | Subfolder output: gives redirects to a trailing slash | | D2 | A small Node step after `vite build` moves the scripts, without an HTML parser dependency | Runs on Start's final output; pure logic is testable; the browser also ends a script at the first `` | Vite plugin hook: ordering against Start's prerender is less clear | | D3 | Moved files are named after their content hash in `/assets` | Long caching is safe, and identical scripts share a file | Fixed names: unsafe with long caching | | D4 | Keep the scripts at the end of the body, where Start puts them | Content renders before they are fetched, which limits the cost of the extra requests | Moving them to the head | | D5 | 404 through a catch-all route rendering the existing `NotFound` | The only tested option without a hydration error | See the spike table | | D6 | One rule for hydration: the first browser render equals the HTML; browser-only values apply afterwards through `useHydrated` or server-safe defaults | Prevents errors in Sentry, jumps and lost performance | Suppressing warnings: hides the problem | | D7 | `Reveal` renders visible by default and hides only what is below the viewport after hydration | The build cannot know the screen size. Content in view never flashes, and content is visible without JavaScript | Hiding in HTML and revealing with JavaScript | | D8 | `