Cookbook

useHead / Page Meta

Manage page titles and head tags with the Ionic-compatible useHead composable.

The module auto-imports an Ionic-compatible implementation of Nuxt's useHead composable. Ionic keeps inactive pages mounted, so Vue's unmount hooks cannot reliably remove their head entries.

Inside a component, the composable associates each head entry with the current route. It disposes the route's entries on onIonViewDidLeave and restores them on onIonViewDidEnter.

Usage

Use it like the standard Nuxt composable:

pages/products/[id].vue
<script setup lang="ts">
const route = useRoute()

useHead({
  title: () => `Product ${route.params.id}`,
  meta: [
    {
      name: 'description',
      content: 'View product details',
    },
  ],
})
</script>
Importing useHead directly from @unhead/vue bypasses the Ionic lifecycle handling.

Usage outside components

Since nuxt-modules/ionic#825, useHead also works without an active component instance. This is required by Nuxt plugins and modules such as @nuxtjs/i18n.

plugins/app-head.ts
export default defineNuxtPlugin(() => {
  useHead({
    titleTemplate: title => title ? `${title} · My App` : 'My App',
  })
})

Without a component instance, the composable skips useRoute, useRouter, and the component lifecycle hooks. The head entry is registered directly and remains active until it is patched or disposed.

The composable returns an entry with patch() and dispose() methods, matching the standard useHead API.

See the Nuxt useHead documentation for supported properties and reactive inputs.
Copyright © 2026