Skip to content

@gluonjs/core / packages/ssr/src / renderResourceHints

Function: renderResourceHints() ​

renderResourceHints(manifest): string

Parameters ​

manifest ​

AssetManifest | undefined

Returns ​

string

Example ​

Serialize module preloads, stylesheets, image preloads, and the client entry from one explicit build asset manifest:

ts
import { css } from '@gluonjs/core';
import {
  createStyleManifest,
  renderResourceHints,
  renderShadowStyleLinks,
  renderStyleCarriers,
  serializeSsrState,
  type AssetManifest,
  type StyleManifest,
  type StyleManifestEntry,
  type ShadowStyleAsset,
} from '@gluonjs/ssr';

const assets = {
  entry: '/assets/client.js',
  imports: ['/assets/vendor.js'],
  styles: ['/assets/app.css'],
  assets: ['/assets/orbit-lamp.webp'],
  shadowStyles: [{ id: 'tailwind', href: '/assets/tailwind.css', digest: '4a1f9d2b' }],
} satisfies AssetManifest;
const shadow: ShadowStyleAsset = assets.shadowStyles[0]!;
const sheet = css`:host { display: block; }`;
const styles: StyleManifest = createStyleManifest([sheet]);
const first: StyleManifestEntry | undefined = styles.entries[0];
const head = renderResourceHints(assets) + renderStyleCarriers(styles, { nonce: 'request-nonce' }) + renderShadowStyleLinks([shadow]);
const state = serializeSsrState({ product: 'Orbit <Lamp>', quantity: 1 });
console.log(first?.digest, head, state);

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