Adding Custom Google Fonts
Let's shift our attention towards the fonts to be used in the app.
The application's fonts are automatically optimized when we use the next/font module with Next.js. The font files are downloaded at build time and hosted with your other static assets. As a result, when a user visits your application, there are no additional network requests for fonts, which helps improve performance.
Back to the Project
Let's add the custom Poppins Google font for our app.
- Create a new file called
fonts.tsinside theapp/uifolder; - Import the
Poppinsfont from thenext/font/googlemodule; - We should also specify the font's
weightandsubsets.
We are ready to use the Poppins font in the app. Let's apply it to the body element in the app/layout.tsx.
As a result, the entire app uses the Poppins font.
In the next chapter, let's include additional fonts.
In Practice
Thanks for your feedback!
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Awesome!
Completion rate improved to 2.08
Adding Custom Google Fonts
Swipe to show menu
Let's shift our attention towards the fonts to be used in the app.
The application's fonts are automatically optimized when we use the next/font module with Next.js. The font files are downloaded at build time and hosted with your other static assets. As a result, when a user visits your application, there are no additional network requests for fonts, which helps improve performance.
Back to the Project
Let's add the custom Poppins Google font for our app.
- Create a new file called
fonts.tsinside theapp/uifolder; - Import the
Poppinsfont from thenext/font/googlemodule; - We should also specify the font's
weightandsubsets.
We are ready to use the Poppins font in the app. Let's apply it to the body element in the app/layout.tsx.
As a result, the entire app uses the Poppins font.
In the next chapter, let's include additional fonts.
In Practice
Thanks for your feedback!