I'm used to importing google fonts in css files and then using the font-family
property. But I want to utilize the "built-in automatic self-hosting" provided by @next/font
.
@next/font includes built-in automatic self-hosting for any font file.
This new font system also allows you to conveniently use all Google Fonts with performance and privacy in mind. CSS and font files are downloaded at build time and self-hosted with the rest of your static assets. No requests are sent to Google by the browser.
So far I can only import and use multiple fonts in index.js
. I want to use the same fonts in another page about.js
without loading the fonts again.
How can I import multiple fonts from @next/font/google
and use them across pages and components?
Is there a way I can attach the fonts to particular classes or selectors?
h1 {
font-family: "Exo 2", sans-serif;
}