@gluonjs/core / src / renderGluonApplicationForServer
Function: renderGluonApplicationForServer()
renderGluonApplicationForServer(
app):TemplateResult
Evaluates an application root with context but without browser mount hooks.
Parameters
app
Returns
Example
Evaluate an unmounted application's root through its application context and return the template for SSR serialization:
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);
}