Astro's new experimental Fonts API solves common web font headaches including privacy concerns (no user IP sent to Google), layout shift, lack of type safety, and unnecessary font downloads. The API downloads fonts at build time rather than runtime, keeping them local to your site. Configuration happens in astro.config.mjs with support for multiple font providers (Google, Fontsource, Adobe, Bunny, local, npm), CSS variables, specific weights/styles/subsets, local fonts, and variable fonts. An optimized fallback feature reduces cumulative layout shift by generating fallback fonts that closely match the target font's metrics.
ā¢9m watch time
Sort: