@gluonjs/ssr


@gluonjs/ssr / 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,
  renderStyleCarriers,
  serializeSsrState,
  type AssetManifest,
  type StyleManifest,
  type StyleManifestEntry,
} from '@gluonjs/ssr';

const assets = {
  entry: '/assets/client.js',
  imports: ['/assets/vendor.js'],
  styles: ['/assets/app.css'],
  assets: ['/assets/orbit-lamp.webp'],
} satisfies AssetManifest;
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' });
const state = serializeSsrState({ product: 'Orbit <Lamp>', quantity: 1 });
console.log(first?.digest, head, state);