Search code examples
javascriptreactjsreact-nativereact-native-cli

How to add fonts for latest version of react native that uses CLI?


I know how to add fonts to react-native linking assets. Now I am using the latest version of react-native 0.61.5 and I am not able to link assets.

Do I still need to use react-native link in such a case. If I use react-native link, It may cause issues to the already linked modules or the modules that need not be linked using react-native link


Solution

  • Create a Root folder called assets and fonts folder inside with your own .ttf files inside.

    Edit react-native.config.js from the root of the project. If you don't have it, create it.

    inside the file you should have something like this.

    module.exports = {   
      project: {
        ios: {},
        android: {}, // grouped into "project"
      },
      assets: ["./assets/fonts"], // stays the same 
    };
    

    after save, run:

    react-native link