| name | mobile-expo-safety |
| description | Expo-specific rules: Metro config, babel, dependencies, build checks, common pitfalls. Load BEFORE adding dependency or editing config. MANDATORY on build errors. |
Expo Safety Rules
⚠️ MANDATORY Compliance
1. Check dependency before adding
NEVER add a package without checking:
- Compatible with current Expo SDK version?
- Need
npx expo install instead of bun/npm install?
- Has native code? (if yes → rebuild app)
npx expo install package-name
bun add package-name
2. Check AFTER every code change
MANDATORY run after changing code:
bun run typecheck
bun run lint
If errors:
- FIX IMMEDIATELY before continuing
- DO NOT commit with errors
- DO NOT ignore warnings
3. Metro config — be careful
File: metro.config.js
DO NOT edit unless:
- Adding resolver for new file type
- Fixing "Unable to resolve module"
- Explicitly requested
If must edit:
- Backup file first
- Test build immediately after
- Comment reason for change
4. Babel config — extremely careful
File: babel.config.js
DO NOT add new plugin unless:
- Checked Expo SDK compatibility
- Necessary for specific feature
- Has example from Expo docs
5. Asset handling
Icons: assets/icons/*.png — import via require()
Fonts: assets/fonts/*.ttf — load via useFonts
Images: assets/ — place in correct directory
Rules:
- Do NOT use absolute paths for assets
- Do NOT import SVG directly (only PNG/JPG)
- Font names must match
useFonts config
Common Expo Pitfalls
1. "Unable to resolve module"
Causes:
- Package installed wrong (
bun add instead of npx expo install)
- Stale Metro cache
- Wrong import path
Fix:
npx expo install --fix
rm -rf node_modules/.cache
npx expo start -c
2. "TypeError: Cannot read property 'X' of undefined"
Causes:
- Native module not linked
- Package incompatible with Expo Go
- Missing rebuild after adding native dependency
Fix:
npx expo run:android
npx expo prebuild --clean
3. Build fail after adding package
Causes:
- Version conflict with Expo SDK
- Native dependency not compatible
- Missing permission in
app.json
Fix:
- Check
package.json — version must match Expo SDK ~54
- Check
app.json — required permissions
npx expo doctor to check health
4. Hot reload not working
Fix:
npx expo start -c
Ctrl+C → npx expo start
5. TypeScript errors out of nowhere
Fix:
rm -rf node_modules/.cache
bun run typecheck
Build Checklist
Before production build:
After build:
Version Management
Expo SDK ~54 compatible dependencies:
expo-router ~6
react-native 0.81
@expo/vector-icons ^15
expo-av ^16
expo-secure-store ~15
DO NOT upgrade version unless:
- Official Expo SDK upgrade
- Clear technical reason
- Tested on both Android and iOS
Native Modules
Warning: Expo Go does not support all native modules
If need native module:
- Check Expo docs — is there a built-in alternative?
- If not →
npx expo prebuild to create native project
- Test on real build (
npx expo run:android/ios)
Native modules in use:
expo-secure-store — token storage
expo-haptics — haptic feedback
expo-av — audio playback/recording
expo-speech — text-to-speech
expo-image-picker — photo upload
expo-linear-gradient — gradients
Double Check Rules
AFTER EVERY CODE SESSION:
- Type check:
bun run typecheck — must PASS
- Lint:
bun run lint — must PASS
- Navigation test: Open app → test modified routes
- API test: Test called endpoint (if any)
- UI test: Check layout on simulator
- Logic test: Verify flow works as planned
DO NOT SKIP ANY STEP.