vue

Best Practices

Master Vue and Unhead by following the best practices.

Avoid Watch and useHead

Avoid wrapping useHead in a watcher.

// bad
watch((title) => {
  useHead({
    title,
  })
})

This is because each call of useHead will add a new entry, which has its own side effects.

Instead, use a computed getter.

// good
useHead({
  title: () => title
})