Challenge - 5 Problems
Next.js Metadata Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate2:00remaining
What is the rendered HTML output of this Next.js Metadata API usage?
Consider this Next.js component using the Metadata API to set the page title and description. What will be the content of the and tags in the rendered HTML?
NextJS
import { Metadata } from 'next'; export const metadata: Metadata = { title: 'Learn Next.js SEO', description: 'A guide to Next.js Metadata API for SEO optimization.' }; export default function Page() { return <main><h1>Welcome to SEO Guide</h1></main>; }
Attempts:
2 left
💡 Hint
Metadata object sets the page's SEO tags automatically.
✗ Incorrect
The Metadata API in Next.js allows you to define SEO tags like title and description at the component level. These tags are rendered in the HTML head automatically.
📝 Syntax
intermediate2:00remaining
Which option correctly defines dynamic metadata in Next.js?
You want to generate metadata dynamically based on props in a Next.js page. Which code snippet correctly uses the Metadata API for this?
Attempts:
2 left
💡 Hint
Dynamic metadata requires an async function named generateMetadata.
✗ Incorrect
Next.js expects an async function named generateMetadata to return metadata dynamically based on route params or props.
🔧 Debug
advanced2:00remaining
Why does this metadata not update on client navigation?
Given this Next.js page with static metadata, why does the page title not update when navigating client-side to a different post?
NextJS
export const metadata = { title: 'Post 1' }; export default function PostPage() { return <div>Post content</div>; }
Attempts:
2 left
💡 Hint
Static metadata is fixed at build time and does not change on client navigation.
✗ Incorrect
Static metadata is set once and does not react to client-side route changes. To update metadata dynamically, use generateMetadata function.
❓ state_output
advanced2:00remaining
What is the final metadata output when combining static and dynamic metadata?
If a Next.js page exports both a static metadata object and an async generateMetadata function, which metadata is used in the rendered page?
NextJS
export const metadata = { title: 'Static Title', description: 'Static description' }; export async function generateMetadata() { return { title: 'Dynamic Title' }; } export default function Page() { return <div>Content</div>; }
Attempts:
2 left
💡 Hint
Dynamic metadata function takes precedence over static metadata.
✗ Incorrect
When both static metadata and generateMetadata exist, Next.js uses the dynamic metadata returned by generateMetadata, ignoring the static object.
🧠 Conceptual
expert2:00remaining
Which statement best describes the role of Next.js Metadata API in SEO?
Select the most accurate description of how Next.js Metadata API improves SEO for web applications.
Attempts:
2 left
💡 Hint
Think about how metadata affects search engines and social platforms.
✗ Incorrect
Next.js Metadata API lets developers define metadata that is rendered on the server, helping search engines and social media platforms understand page content better.