--- title: "entries:resolve Hook" description: "Learn about the entries:resolve hook in Unhead that processes entries before they're converted to tags" navigation: title: "entries:resolve" --- The `entries:resolve` hook is called when head entries need to be resolved into tags. This hook provides access to both the entries and the tags being generated, allowing you to modify or add to the collection before the final tag resolution process. ## Hook Signature ```ts export interface Hook { 'entries:resolve': (ctx: EntryResolveCtx<any>) => HookResult } ``` ### Parameters | Name | Type | Description | |------|------|-------------| | `ctx` | `EntryResolveCtx<any>` | Context containing the entries and tags being processed | The `EntryResolveCtx` interface is defined as: ```ts interface EntryResolveCtx<T> { tags: HeadTag[] entries: HeadEntry<T>[] } ``` ### Returns `HookResult` which is either `void` or `Promise<void>` ## Usage Example ```ts import { createHead } from '@unhead/dynamic-import' const head = createHead({ hooks: { 'entries:resolve': (ctx) => { // Inspect the entries being processed console.log(`Processing ${ctx.entries.length} head entries`) // You can modify or add to the tags collection ctx.tags.push({ tag: 'meta', props: { name: 'generator', content: 'Unhead' } }) } } }) ``` ## Use Cases ### Adding Global Meta Tags Use this hook to add global meta tags that should be present on all pages: ```ts import { defineHeadPlugin } from '@unhead/dynamic-import' export const globalMetaPlugin = defineHeadPlugin({ hooks: { 'entries:resolve': (ctx) => { // Add global meta tags ctx.tags.push( { tag: 'meta', props: { name: 'author', content: 'Your Company' } }, { tag: 'meta', props: { property: 'og:site_name', content: 'Your Application' } } ) } } }) ``` ### Extracting Information from Entries You can use this hook to extract and process information from entries: ```ts import { defineHeadPlugin } from '@unhead/dynamic-import' export const analyticsDataPlugin = defineHeadPlugin({ hooks: { 'entries:resolve': (ctx) => { // Extract all page titles and descriptions for analytics const pageData = ctx.entries.reduce((acc, entry) => { const input = entry.input if (typeof input === 'object') { if ('title' in input) { acc.title = input.title } if ('meta' in input && Array.isArray(input.meta)) { const descMeta = input.meta.find(m => m.name === 'description' || m.property === 'og:description' ) if (descMeta) { acc.description = descMeta.content } } } return acc }, {}) // Use the extracted data if (!ctx.entries[0].options.ssr) { logPageView(pageData) } } } }) function logPageView(data) { // Send data to analytics service console.log('Logging page view:', data) } ```