Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Build performant React Native and Expo apps with best practices for lists, animations, and navigation
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
rules/fonts-config-plugin.md
1---2title: Load fonts natively at build time3impact: LOW4impactDescription: fonts available at launch, no async loading5tags: fonts, expo, performance, config-plugin6---78## Use Expo Config Plugin for Font Loading910Use the `expo-font` config plugin to embed fonts at build time instead of11`useFonts` or `Font.loadAsync`. Embedded fonts are more efficient.1213**Incorrect (async font loading):**1415```tsx16import { useFonts } from 'expo-font'17import { Text, View } from 'react-native'1819function App() {20const [fontsLoaded] = useFonts({21'Geist-Bold': require('./assets/fonts/Geist-Bold.otf'),22})2324if (!fontsLoaded) {25return null26}2728return (29<View>30<Text style={{ fontFamily: 'Geist-Bold' }}>Hello</Text>31</View>32)33}34```3536**Correct (config plugin, fonts embedded at build):**3738```json39// app.json40{41"expo": {42"plugins": [43[44"expo-font",45{46"fonts": ["./assets/fonts/Geist-Bold.otf"]47}48]49]50}51}52```5354```tsx55import { Text, View } from 'react-native'5657function App() {58// No loading state needed—font is already available59return (60<View>61<Text style={{ fontFamily: 'Geist-Bold' }}>Hello</Text>62</View>63)64}65```6667After adding fonts to the config plugin, run `npx expo prebuild` and rebuild the68native app.6970Reference:71[Expo Font Documentation](https://docs.expo.dev/versions/latest/sdk/font/)72