Configure unhead v2 in Nuxt 15.6
Hi!
In
unhead
v2, the template param is opt-in.
Documentation says to:
How can I do this in Nuxt 3.15.6 ? Should I create a new defineNuxtPlugin with unhead in it?2 Replies
Hi @ok3n. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Yes, you're correct that in Unhead v2, the template params feature is now opt-in. In Nuxt 3, you can enable this feature by creating a Nuxt plugin that accesses the head instance and adds the plugin.
According to the Nuxt 4 upgrade guide, you can implement this as follows:
This plugin should be placed in your
plugins
directory. The injectHead()
function gives you access to the Unhead instance that Nuxt is using internally, allowing you to add plugins to it.
Note that the import path is @unhead/vue/plugins
rather than unhead/plugins
as shown in the vanilla Unhead documentation, since Nuxt uses the Vue integration of Unhead.
If you're experiencing issues with this approach, you can alternatively enable legacy mode in your Nuxt config, which will restore the v1 behavior:
However, using the plugin approach is recommended for forward compatibility.
Nuxt 4 Upgrade Guide
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@407208375349280778> Kapa.ai is still learning and improving, please let me know how I did by reacting below.