Consider a Next.js app that uses the next/font/local to load a self-hosted font with font optimization enabled. What will be the visible effect on the page's text?
import localFont from 'next/font/local'; const myFont = localFont({ src: './fonts/MyFont.woff2', display: 'swap', }); export default function Home() { return <main className={myFont.className}>Hello World</main>; }
Think about the display: 'swap' option and how it affects font loading behavior.
Using display: 'swap' causes the browser to use a fallback font immediately and swap to the custom font once it loads, preventing invisible text.
Identify the correct way to import and apply the Inter font from Google Fonts using Next.js built-in font optimization.
Check the correct import syntax and the expected options object for subsets.
The correct import uses named import { Inter } and the options object must specify subsets as an array.
Given this code, the custom font does not appear on the page. What is the most likely cause?
import localFont from 'next/font/local'; const myFont = localFont({ src: './fonts/CustomFont.woff2', }); export default function Home() { return <div className={myFont.className}>Hello</div>; }
Remember how Next.js handles the public folder for static assets.
Next.js serves files in public folder at the root URL, so the path should be relative to the file, not including 'public'.
When you import Google Fonts using Next.js built-in font optimization, what happens to the font loading and page performance?
Think about how Next.js optimizes font loading to improve user experience.
Next.js preloads fonts and injects CSS to avoid layout shifts and speed up font rendering.
Choose the most accurate description of how Next.js handles self-hosted fonts versus Google Fonts with its font optimization feature.
Consider how Next.js manages font files and optimization differently for these two sources.
Self-hosted fonts need you to provide font files and paths, while Google Fonts are fetched and optimized automatically by Next.js.