Plugins

Treeshaking

Remove composables from your client builds.

Unhead provides a Vite plugin to optimise your builds, by removing composables that aren't needed and simplifying your code.

While optional, it's recommended for most use cases to ensure Unhead runs optimally.

It will perform the following optimisations:

  • Remove server composables in client builds (e.g. useServerHead, useServerSeoMeta)
  • Transform useSeoMeta to raw useHead (saves ~3kb)

Setup

  1. Install the @unhead/addons package.
yarn
yarn add -D @unhead/addons
  1. Add the plugin to your build config.
vite.config.ts
import UnheadVite from '@unhead/addons/vite'
import { defineConfig } from 'vite'

export default defineConfig({
  plugins: [
    UnheadVite(),
  ],
})