--- title: useHeadSafe() description: API reference for the useHeadSafe composable that provides security features for head tags. --- The `useHeadSafe` composable is a security-focused wrapper around the [useHead](/docs/head/api/composables/use-head) composable that restricts input to only allow safe values, providing protection against XSS attacks when working with untrusted content. ## How It Works The composable implements a strict whitelist of allowed tags and attributes. When you attempt to use a tag or attribute that isn't on the whitelist, it will be silently ignored to prevent potential security issues. ::warning The whitelist is intentionally restrictive since there are many vectors for XSS attacks. If you need to use a tag or attribute that isn't on the whitelist, you can use the [useHead](/docs/head/api/composables/use-head) composable instead, but **you must sanitize the input yourself**. :: ### Security Whitelist The security whitelist specifies which attributes are allowed for each tag type: ```ts import { useHeadSafe } from '@unhead/dynamic-import' // The whitelist used internally by useHeadSafe const WhitelistAttributes = { htmlAttrs: ['class', 'style', 'lang', 'dir'] satisfies (keyof HtmlAttributes)[], bodyAttrs: ['class', 'style'] satisfies (keyof BodyAttributes)[], meta: ['name', 'property', 'charset', 'content', 'media'] satisfies (keyof Meta)[], noscript: ['textContent'] satisfies (Partial | 'textContent')[], style: ['media', 'textContent', 'nonce', 'title', 'blocking'] satisfies (Partial | 'textContent')[], script: ['type', 'textContent', 'nonce', 'blocking'] satisfies (Partial | 'textContent')[], link: ['color', 'crossorigin', 'fetchpriority', 'href', 'hreflang', 'imagesrcset', 'imagesizes', 'integrity', 'media', 'referrerpolicy', 'rel', 'sizes', 'type'] satisfies (keyof Link)[], } as const ``` ### Additional Restrictions ::note The following security restrictions also apply: :: - Scripts of any sort are not allowed, except for JSON (`