---
title: "Lazy Head"
description: "API reference for queuing head entries and loading the client head on demand."
canonical_url: "https://unhead.unjs.io/docs/head/api/lazy-head"
---

> Index of every page on this site: [llms.txt](https://unhead.unjs.io/llms.txt)

`createHead()` returns a small client shell. It queues head entries until the app calls `load()`, then forwards updates to the client head.

<note>

The lazy head is experimental. Its API may change in a minor release.

</note>

<table>
<thead>
  <tr>
    <th>
      Entry point
    </th>
    
    <th>
      Exports
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        @unhead/vue/lazy
      </code>
    </td>
    
    <td>
      <code>
        createHead
      </code>
      
      , <code>
        LazyHeadOptions
      </code>
      
      , and <code>
        LazyVueHead
      </code>
      
      . The shell also installs as a Vue plugin.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        @unhead/react/lazy
      </code>
    </td>
    
    <td>
      <code>
        createHead
      </code>
      
       and <code>
        UnheadProvider
      </code>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        @unhead/svelte/lazy
      </code>
    </td>
    
    <td>
      <code>
        createHead
      </code>
      
       and <code>
        UnheadContextKey
      </code>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        @unhead/solid-js/lazy
      </code>
    </td>
    
    <td>
      <code>
        createHead
      </code>
      
       and <code>
        UnheadContext
      </code>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        unhead/lazy
      </code>
    </td>
    
    <td>
      <code>
        createHead
      </code>
      
      , <code>
        LazyHeadOptions
      </code>
      
      , and <code>
        LazyUnhead
      </code>
      
      . Use this entry point for framework adapters.
    </td>
  </tr>
</tbody>
</table>

## Options

`LazyHeadOptions` accepts the client `createHead()` options. The `hooks` and `plugins` options register when the runtime activates.

<table>
<thead>
  <tr>
    <th>
      Option
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        streamKey
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      Connect to the queue written by the matching server bootstrap. Omit for buffered SSR or a client-only page.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        lazyPlugins
      </code>
    </td>
    
    <td>
      <code>
        () => Promise<HeadPluginInput[]>
      </code>
    </td>
    
    <td>
      Load plugins with the runtime. Use dynamic imports to keep plugin code out of the initial bundle.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        hookable
      </code>
    </td>
    
    <td>
      <code>
        HookableCore<ClientHeadHooks>
      </code>
    </td>
    
    <td>
      Supply a hook registry when a framework integration subscribes to hooks before activation.
    </td>
  </tr>
</tbody>
</table>

A custom `render` option controls rendering from activation onward. The default renderer adopts the server tags and applies queued changes.

## Methods

<table>
<thead>
  <tr>
    <th>
      Method
    </th>
    
    <th>
      Behavior
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        push(input, options?)
      </code>
    </td>
    
    <td>
      Add an entry. Its <code>
        patch()
      </code>
      
       and <code>
        dispose()
      </code>
      
       work before and after activation.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        use(plugin)
      </code>
    </td>
    
    <td>
      Register a plugin on activation or register it immediately if the runtime is active.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        finishHydration()
      </code>
    </td>
    
    <td>
      Mark the end of hydration. Call this when your framework finishes collecting the initial entries.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        discardStream()
      </code>
    </td>
    
    <td>
      Drop pending and applied patches from the initial server stream. Call this when leaving its page. It leaves runtime loading to the caller.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        load()
      </code>
    </td>
    
    <td>
      Load and return the full client head as a <code>
        Promise
      </code>
      
      . Concurrent calls share the load.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        render()
      </code>
    </td>
    
    <td>
      Forward to the client head when active. Before activation, return <code>
        false
      </code>
      
      .
    </td>
  </tr>
</tbody>
</table>

For streaming, call `load()` once the matching server bootstrap is present. If the stream queue is missing or a plugin loader fails, `load()` rejects. Fix the cause, then call `load()` again.

`finishHydration()` and `render()` leave activation to the caller. In development, `finishHydration()` can check for differences between queued client tags and the server tags on buffered SSR pages.

Vue's `useScript()` can register scripts before the runtime loads. Framework integrations that access `head.hooks` directly before calling `useScript()` can supply `hookable` when they create the shell. Subscriptions carry through activation. Plugins can read `entries` during tag resolution.

Use the full client head returned by `load()` for other runtime APIs.

## Preload the runtime

The framework Vite plugin adds a low-priority `modulepreload` hint to production HTML that uses the lazy head. Use `Unhead({ lazyHeadPreload: false })` to fetch the runtime when your app calls `load()`.

See the setup guides for [Vue](https://unhead.unjs.io/docs/vue/head/guides/core-concepts/lazy-head), [React](https://unhead.unjs.io/docs/react/head/guides/core-concepts/lazy-head), [Svelte](https://unhead.unjs.io/docs/svelte/head/guides/core-concepts/lazy-head), and [Solid](https://unhead.unjs.io/docs/solid-js/head/guides/core-concepts/lazy-head).

## Sitemap

See the full [sitemap](https://unhead.unjs.io/sitemap.md) for all pages.
