Skip to main content
InterviewHubPRO
Section Overview
Q9

Question 9 of 50

Part 1: Nuxt 3 Fundamentals (Junior / Entry-Level)

18%
Nuxt & Universal SSR (50 Qs)•Part 1: Nuxt 3 Fundamentals (Junior / Entry-Level)

How do you handle SEO metadata with `useHead()` and `useSeoMeta()`?

mid LevelCode ExampleVue & Nuxt

In Simple Words: Nuxt 3 uses @unhead/vue under the hood. useSeoMeta() provides type-safe, auto-completing helper functions to define standard meta tags, OpenGraph cards, Twitter preview cards, and canonical links that are injected directly into the server-rendered HTML <head>.

vue
<script setup lang="ts">
const { data: article } = await useFetch('/api/articles/123');

useSeoMeta({
  title: () => article.value?.title ?? 'Default Title',
  description: () => article.value?.excerpt,
  ogTitle: () => article.value?.title,
  ogDescription: () => article.value?.excerpt,
  ogImage: 'https://cdn.example.com/og-image.jpg',
  twitterCard: 'summary_large_image',
});
</script>