@vueuse/head
Super-charged document head management for Vue, powered by unhead.
## ✨ v1 released!
Read the announcement [post](https://harlanzw.com/blog/vue-use-head-v1), provide any feedback or questions in [this discussion](https://github.com/vueuse/head/discussions/161)
## Features
- 💎 Fully typed augmentable Schema
- 🧑🤝🧑 Side-effect based DOM patching, plays nicely your existing other tags and attributes
- 🍣 Intuitive deduping, sorting, title templates, class merging and more
- 🪝 Extensible hook / plugin based API
## Installation
```bash
npm i @vueuse/head
# Or Yarn
yarn add @vueuse/head
```
> Requires vue >= v3 or >=2.7
## Usage
### Vue 3
Register the Vue plugin:
```ts
import { createApp } from "vue"
import { createHead } from "@vueuse/head"
const app = createApp()
const head = createHead()
app.use(head)
app.mount("#app")
```
### Vue 2
Register the Vue plugin:
```ts
import Vue from 'vue'
import { createHead, HeadVuePlugin } from "@vueuse/head"
const head = createHead()
// needed for Vue 2
Vue.use(HeadVuePlugin, head)
Vue.use(head)
new Vue({
render: h => h(App),
}).$mount('#app')
```
### SSR Rendering
```ts
import { renderToString } from "@vue/server-renderer"
import { renderHeadToString } from "@vueuse/head"
const appHTML = await renderToString(yourVueApp)
// `head` is created from `createHead()`
const { headTags, htmlAttrs, bodyAttrs, bodyTags } = renderHeadToString(head)
const finalHTML = `
${headTags}
${appHTML}
${bodyTags}
`
```
## Further Documentation
Refer to the [unhead documentation](https://unhead.harlanzw.com/) for full API reference and more.
## Sponsors
## License
MIT © [EGOIST](https://egoist.sh)
MIT License © 2022-PRESENT [Harlan Wilton](https://github.com/harlan-zw)