The config plugin needs a development build and never runs on web. useFonts from expo-font loads font files from JavaScript when the app starts and keeps track of the loading state, and it works in Expo Go and on Android, iOS and web. The price is a short wait before text can use the font, so the root component has to decide what to show until the files are ready.
Key terms
- useFonts: a hook exported by
expo-fontthat loads fonts at runtime and returns a[loaded, error]tuple. - FontSource: where a font comes from, given as a URI string, the module ID that
requirereturns, anAssetfromexpo-asset, or aFontResourceobject. - @expo-google-fonts: the set of packages, such as
@expo-google-fonts/inter, that make every font listed in Google Fonts available to Expo apps.
Family names as keys
useFonts takes a font map and returns [boolean, Error | null]. In the object form of the map, each key is a fontFamily name you choose and each value is a FontSource. Every key is loaded as a separate font family, and the key is the name a <Text> later passes to fontFamily. With runtime loading there is no file-name rule to remember, because you pick the name.
Call the hook in a top-level component such as the root layout, src/app/_layout.tsx, so loading starts with the app. The default template maps the @/assets/* import alias to the assets folder at the project root, and its own screens load bundled files with paths like require('@/assets/images/react-logo.png'). The Halcyon root layout below uses the same alias for its two font files.
What loaded and error tell you
loaded is a boolean that says whether the fonts have finished loading. error holds the Error hit while loading, and stays null when nothing goes wrong. On native, the hook starts loaded from whether the fonts are already loaded, calls loadAsync once, then sets loaded to true on success or stores the failure in error.
That is why the root layout guards with if (!loaded && !error) return null;. It renders nothing while loading is still in progress, and renders the app as soon as either value is set, so a font that fails to load doesn't leave the screen blank.
One remote-font example in the fonts guide writes the guard as !loaded || !error. Don't copy it. After a successful load, error is still null, so !error stays true and that screen never renders.
Failures come back as errors from loadAsync. A map entry whose source is null or undefined fails with the code ERR_FONT_SOURCE. On native, a font file that fails to download makes loadAsync reject with the download error from expo-asset, which passes the native error through unchanged. Because loadAsync rejects in both cases, useFonts reports them in error.
The hook loads once. Its effect runs with an empty dependency list, so the fonts are not reloaded when you change the font map passed to it. Settle the full set of fonts in the first render of the component that calls it.
A FontSource can also be a URL string in place of a require call, which loads the font from a server. On web, the server must send the font with CORS configured, or the font may not load.
Google Fonts as packages
Every font in Google Fonts is available through @expo-google-fonts. Each package provides its own useFonts hook and imports the font file for you, so there is no require path to get right. For Inter the install command is npx expo install @expo-google-fonts/inter expo-font expo-splash-screen, where expo-splash-screen is there to keep the splash screen up until the font is ready. The component then imports the font and the hook together with import { Inter_900Black, useFonts } from '@expo-google-fonts/inter';, passes Inter_900Black in the map, and styles text with fontFamily: 'Inter_900Black'.
The same packages work with the config plugin. Point the plugin's fonts array at the file inside node_modules, such as node_modules/@expo-google-fonts/inter/900Black/Inter_900Black.ttf. A Google Font embedded this way has the same benefits and limitations as your own embedded file.
Plugin or hook for a given project
On Android and iOS the config plugin is the recommended method, and the API reference's own example reserves useFonts for when you can't use the plugin. A project that builds development builds and ships only native apps gets fonts that are ready at launch, with no guard in the root layout.
On native, a font served from a URL still goes through the hook, because plugin paths point to font files in the project.
Code Examples
import { useFonts } from 'expo-font';
import { Stack } from 'expo-router';
export default function RootLayout() {
const [loaded, error] = useFonts({
'Halcyon-Regular': require('@/assets/fonts/Halcyon-Regular.otf'),
'Halcyon-Bold': require('@/assets/fonts/Halcyon-Bold.otf'),
});
// Render nothing until loading succeeds or fails.
if (!loaded && !error) {
return null;
}
return <Stack />;
}