Next.js
/Beginner
Metadata API
Definition
The built-in Next.js system for defining `<head>` elements like `<title>`, `<meta name="description">`, and favicons.
Explain Like I'm New
If you don't define a Title, the Google tab just shows the raw URL, which looks terrible. In Next.js, you just export a `metadata` object from your `page.tsx` or `layout.tsx`, and Next.js perfectly injects it into the HTML head for you.
Real World Example
Setting the global website title ('My Cool Startup') in the root `layout.tsx`, and overriding it with a specific title ('Pricing | My Cool Startup') on the pricing page.
Common Use Cases
- •Search Engine Optimization (SEO)
- •Browser tab titles
- •Favicons
Interactive Example
Loading Code Playground...
Interview Questions
basic
- What object must you export from a `page.tsx` file to set the page title?
intermediate
- Can you export the `metadata` object from a Client Component (`'use client'`)?