---
title: "Vite Plugin Tags"
description: "Convert Vite HTML tag descriptors into Unhead input for SSR."
canonical_url: "https://unhead.unjs.io/docs/head/guides/build-plugins/vite-plugin-tags"
---

> Index of every page on this site: [llms.txt](https://unhead.unjs.io/llms.txt)

Use `htmlTagsToHead()` when your SSR integration already has Vite HTML tag descriptors. The helper does not collect descriptors.

Call `prepareViteHead()` once when you load a manifest. Call the returned function for each request. If the manifest changes, prepare the new descriptors.

```ts
import type { HtmlTagDescriptor } from 'unhead/vite'
import { createHead, prepareHeadInput } from 'unhead/server'
import { htmlTagsToHead } from 'unhead/vite'

export function prepareViteHead(tags: readonly HtmlTagDescriptor[]) {
  const viteHead = prepareHeadInput(htmlTagsToHead(tags))
  return () => createHead({ init: [viteHead] })
}
```

Keep the prepared input immutable so Unhead can reuse normalized tags across requests. `prepareHeadInput()` is experimental.

The helper accepts flat `base`, `link`, `meta`, `noscript`, `script`, and `style` descriptors. Use string children for inline content from trusted plugins.

Omitted `injectTo` and `head-prepend` give a tag high priority. `head`, `body-prepend`, and `body` map to the head, start of the body, and end of the body. Unhead applies its normal deduplication and CAPO ordering. For `base`, the first supplied `href` and `target` win in Vite's head placement order.

If conversion throws `TypeError`, send the original batch through your framework's HTML transform. Use that path for unsupported tags or placements, nested descriptors, and attributes that Unhead would reinterpret. Examples include `key`, `class`, `style`, and strings that look like HTML character references.
Conversion also throws when a batch contains `module` and `nomodule` scripts that Unhead would deduplicate.

Vite's manifest support is tracked in [vitejs/ecosystem#15](https://github.com/vitejs/ecosystem/issues/15).

## Sitemap

See the full [sitemap](https://unhead.unjs.io/sitemap.md) for all pages.
