Hooks
entries:updated Hook
On this page
The entries:updated hook runs when a client head entry is added, patched, disposed, or invalidated. Unhead's client adapter uses this hook to trigger DOM rendering.
The server adapter does not emit this hook when entries change. On the server, rendering begins when you call head.render().
Hook Signature
export interface Hook {
'entries:updated': (head: Unhead<any>) => HookResult
}
type HookResult = void | Promise<void>
Parameters
| Name | Type | Description |
|---|---|---|
head | Unhead<any> | The Unhead instance whose entries changed |
Although the type permits a promise, the client update path does not await hook results. Keep this hook synchronous. ValidatePlugin warns when a hook returns a promise that Unhead will ignore.
Usage Example
import { defineHeadPlugin } from 'unhead/plugins'
export const entryCountPlugin = defineHeadPlugin({
key: 'entry-count',
hooks: {
'entries:updated': (head) => {
console.log(`Active head entries: ${head.entries.size}`)
}
}
})
Entry inputs may still contain framework-specific reactive values at this point. Use a tag-resolution hook when you need normalized tag data.
Did this page help you?
On this page