Overview
A monorepo structure for Expo:Workspace Managers
Yarn Workspaces
package.json (root)
npm Workspaces
package.json (root)
pnpm Workspaces
pnpm-workspace.yaml
package.json (root)
Setting Up
Metro Configuration
Configure Metro to resolve workspace packages.Basic Config
apps/mobile/metro.config.js
Advanced Config
apps/mobile/metro.config.js
TypeScript Configuration
Root Config
tsconfig.json (root)
App Config
apps/mobile/tsconfig.json
Package Config
packages/shared-components/tsconfig.json
Shared Packages
Component Library
packages/shared-components/src/Button.tsx
packages/shared-components/src/index.ts
Utility Library
packages/shared-utils/src/format.ts
packages/shared-utils/src/index.ts
Using Shared Code
apps/mobile/app/index.tsx
Native Modules in Monorepos
Autolinking
Expo modules need special handling:apps/mobile/metro.config.js
Custom Native Modules
packages/my-native-module/package.json
Building and Deployment
Local Builds
EAS Build
EAS Build automatically supports monorepos:apps/mobile/eas.json
CI/CD
.github/workflows/build.yml
Troubleshooting
Metro Can’t Resolve Module
Duplicate Module in Graph
metro.config.js
Native Module Not Found
Build Fails: Package Not Found
Best Practices
1. Use Path Aliases
tsconfig.json
2. Shared ESLint Config
.eslintrc.js (root)
apps/mobile/.eslintrc.js
3. Hoisted Dependencies
package.json (root)
4. Build Scripts
package.json (root)
Next Steps
Prebuild
Generate native projects in monorepos
Build Properties
Configure builds
Native Modules
Create shared native modules
Testing
Test across packages