Skip to content

@gluonjs/core / src / renderGluonApplicationForServer

Function: renderGluonApplicationForServer() ​

renderGluonApplicationForServer(app): TemplateResult

Evaluates an application root with context but without browser mount hooks.

Parameters ​

app ​

GluonApp

Returns ​

TemplateResult

Example ​

Evaluate an unmounted application's root through its application context and return the template for SSR serialization:

ts
import {
  createApp,
  disposeGluonApplicationForServer,
  html,
  renderGluonApplicationForServer,
} from '@gluonjs/core';
import { renderToString } from '@gluonjs/ssr';

const app = createApp(() => html`<main>Server-owned shop</main>`);
try {
  const template = renderGluonApplicationForServer(app);
  console.log(await renderToString(template));
} finally {
  await disposeGluonApplicationForServer(app);
}

Version-matched documentation. Examples are checked against the public package contracts.