Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vueuse/head

Package Overview
Dependencies
Maintainers
3
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vueuse/head

Document head manager for Vue 3. SSR ready.

  • 1.1.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
118K
decreased by-4.27%
Maintainers
3
Weekly downloads
 
Created
Source

@vueuse/head

NPM version NPM Downloads GitHub stars

Document head management for Vue. Powered by Unhead.


Created by egoist, maintained by harlan-zw
💛 Support ongoing development by sponsoring us.
Follow 🐦 @harlan_zw for updates • Join Discord for support

v1.1.0 released

  • :sparkles: New Tag: templateParams
  • 🎉 New useHeadSafe
  • and much more!

Read the release notes.

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

npm i @vueuse/head
# Or Yarn
yarn add @vueuse/head

Requires vue >= v3 or >=2.7

Usage

Vue 3

Register the Vue plugin:

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:

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

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 } = await renderHeadToString(head)

const finalHTML = `
<html${htmlAttrs}>

  <head>
    ${headTags}
  </head>

  <body${bodyAttrs}>
    <div id="app">${appHTML}</div>
    ${bodyTags}
  </body>

</html>`

Further Documentation

Refer to the unhead documentation for full API reference and more.

Sponsors

License

MIT © EGOIST MIT License © 2022-PRESENT Harlan Wilton

Keywords

FAQs

Package last updated on 25 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc