@gluonjs/ssr


@gluonjs/ssr / packages/ssr/src / SsrRequestResult

Interface: SsrRequestResult

Properties

readonly head: string


html

readonly html: string


router

readonly router: RouterSnapshot


state

readonly state: string


stateScript

readonly stateScript: string


store

readonly store: StoreSnapshot


styles

readonly styles: StyleManifest

Example

Consume the rendered body, safe state carrier, head resources, style manifest, and Router/Store snapshots produced before request cleanup:

ts
import { createApp, html } from '@gluonjs/core';
import { renderRequest, type SsrRequestContext, type SsrRequestOptions, type SsrRequestResult } from '@gluonjs/ssr';

type ReportData = { title: string };
const options = {
  url: '/reports/41',
  routes: [{ path: '/reports/:id', name: 'report' }],
  load: ({ router }: Omit<SsrRequestContext<ReportData>, 'data'>) => ({ title: `Report ${router.currentRoute.value.params.id}` }),
  createApp: ({ data }) => createApp(() => html`<main>${data.title}</main>`),
} satisfies SsrRequestOptions<ReportData>;

const response: SsrRequestResult = await renderRequest(options);
console.log(response.html, response.stateScript);