For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /apis/app/runtime/utility/head.md.

Head

Used to add html elements (such as title, meta, script, etc.) to the <head> element, supports SSR.

Usage

import { Helmet } from '@modern-js/runtime/head';

export default () => <Helmet>...</Helmet>;

Example

import { Helmet } from '@modern-js/runtime/head';

function IndexPage() {
  return (
    <div>
      <Helmet>
        <title>My page title</title>
        <meta name="viewport" content="initial-scale=1.0, width=device-width" />
      </Helmet>
      <p>Hello Modern.js!</p>
    </div>
  );
}

export default IndexPage;

More

For detail, see react-helmet.