installSsr
uses tcmts.cli.web.ssrRequests, which uses node:async_hooks
What the browser runtime's stubs use while a page renders on the server (globalThis.__tcmSsr), and the page's
location, so browser code reading the URL renders the same on both sides. Both follow the request being
rendered; outside one, location is undefined, as it always is in Node.
import { ssrRequests } from "#codebase/tcmts/cli/web"; export function installSsr() { const g = globalThis as { __tcmSsr?: unknown }; if (g.__tcmSsr) return; g.__tcmSsr = { cache: () => ssrRequests.getStore()!.cache, render: (hash: string, body: string, write: (text: string) => void) => ssrRequests.getStore()!.render(hash, body, write), }; Object.defineProperty(globalThis, "location", { configurable: true, get: () => ssrRequests.getStore()?.url, }); }