0
0
NextJSframework~5 mins

Font optimization with next/font in NextJS - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the main purpose of using next/font in a Next.js project?
The main purpose is to optimize font loading by automatically handling font subsets, preloading, and reducing layout shifts, which improves page speed and user experience.
Click to reveal answer
intermediate
How does next/font help reduce layout shifts caused by fonts?
It preloads fonts and uses font subsets to ensure text renders quickly and consistently, preventing visible changes in text size or style after the page loads.
Click to reveal answer
beginner
Which font types can be optimized using next/font?
You can optimize Google Fonts, local fonts, and custom fonts by importing them through next/font/google or next/font/local.
Click to reveal answer
intermediate
What is the benefit of using font subsets in next/font?
Font subsets load only the characters needed for your content, which reduces font file size and speeds up page loading.
Click to reveal answer
beginner
Show a simple example of importing and using a Google Font with next/font.
Example:
<pre>import { Roboto } from 'next/font/google';
const roboto = Roboto({ subsets: ['latin'], weight: '400' });

export default function Home() {
  return <main className={roboto.className}>Hello with Roboto font!</main>;
}</pre>
Click to reveal answer
What does next/font automatically do to improve font loading?
APreloads fonts and uses subsets
BConverts fonts to images
CRemoves all fonts from the page
DLoads fonts only after user clicks
Which import would you use to load a Google Font with next/font?
Aimport Roboto from 'next/font/remote';
Bimport Roboto from 'next/font/local';
Cimport { Roboto } from 'next/font/custom';
Dimport { Roboto } from 'next/font/google';
Why are font subsets useful in next/font?
AThey load only needed characters to reduce file size
BThey add extra characters for all languages
CThey disable font loading
DThey convert fonts to SVG
What is a key benefit of using next/font over traditional font loading?
AFonts are embedded as base64 images
BFonts load slower but look better
CImproved performance and less layout shift
DFonts are only loaded on mobile devices
How do you apply a font loaded with next/font to a component?
ASet the font in a CSS file manually
BUse the font's <code>className</code> on an element
CFonts apply automatically without code
DUse inline styles with font URL
Explain how next/font improves font loading and user experience in Next.js.
Think about speed and how fonts appear on the page.
You got /4 concepts.
    Describe the steps to import and use a Google Font with next/font in a Next.js component.
    Focus on import, configuration, and usage.
    You got /3 concepts.