Note: This post corresponds to React Native 0.69+.
- Get the fonts that you want to use in your app. You can search and download the fonts from Google Fonts as it has a huge collection of free fonts.
- After downloading the fonts, make sure that you've placed the fonts in a 'fonts' folder under the 'assets' directory at the root of your application.
PROJECT-DIRECTORY/assets/fonts
Adding Configuration File
- Create a new file at the root of your project entitled
react-native.config.js.
- Insert these lines into the file:
Linking Configuration File
- As of React Native 0.69+, you just have to run this command below to link the configuration file to both iOS and Android project files:
- That's about it! Now you can use
fontFamily:'Nunito-Bold'
in your code. - If in case the font is not loading in the app simulator, just restart the simulator with either
npx react-native run-ios
for iOS simulator, ornpx react-native run-android
for Android simulator. The project will be rebuilt with the recent changes/link you've added to the project.
September 15, 2022