Skip to main content
Expo supports monorepo setups where multiple packages and apps share dependencies and code. This guide covers configuration and best practices.

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

1

Initialize root package

package.json
2

Create Expo app

3

Create shared packages

packages/shared-components/package.json
4

Link packages

apps/mobile/package.json

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

Solution:

Duplicate Module in Graph

Solution:
metro.config.js

Native Module Not Found

Solution:

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