Skip to main content
Metro is the JavaScript bundler used by Expo and React Native. You can customize Metro’s behavior using a metro.config.js file in your project root.

Default Configuration

Expo provides a default Metro configuration optimized for Expo projects. Create a basic metro.config.js:
metro.config.js
This gives you:
  • Web support with React Native Web
  • Asset handling for images, fonts, etc.
  • TypeScript support
  • CSS support (experimental)
  • Multi-platform resolution
  • Symlink support for monorepos

Configuration Structure

Metro configuration has several key sections:
metro.config.js

Common Customizations

Adding File Extensions

Support additional file extensions:
metro.config.js

Custom Asset Types

Register custom asset types:
metro.config.js

Alias Module Paths

Create import aliases:
metro.config.js
Use in your code:

Block List (Ignore Files)

Exclude files from bundling:
metro.config.js

Extra Node Modules

Add additional node_modules locations:
metro.config.js

Monorepo Configuration

For monorepo setups with multiple packages:
metro.config.js

Custom Transformers

Babel Transformer

Use a custom Babel transformer:
metro.config.js

SVG Transformer

Support SVG as React components: First, install the transformer:
Then configure Metro:
metro.config.js
Use SVGs in your code:

Platform-Specific Extensions

Metro automatically resolves platform-specific files:
Customize the order:
metro.config.js

Custom Resolvers

Implement custom module resolution:
metro.config.js

Web-Specific Configuration

Customize web bundling:
metro.config.js

Performance Optimization

Parallel Workers

Control the number of workers:
metro.config.js

Cache Configuration

Customize caching:
metro.config.js

Reset Cache

Clear Metro cache:
Or manually:

TypeScript Support

Metro supports TypeScript out of the box with Expo’s default config. Configure additional options:
metro.config.js

Environment-Specific Configuration

Different configs for different environments:
metro.config.js

Debugging Metro

Enable Logging

metro.config.js

Verbose Output

Run with verbose logging:

Common Issues

Module Not Found

If Metro can’t find modules:
  1. Check sourceExts:
  2. Check watchFolders:
  3. Clear cache:
For symlinked packages:
metro.config.js

Slow Bundling

Optimize performance:
metro.config.js

Best Practices

Keep It Simple

Start with the default config and only customize when needed:

Document Customizations

Add comments explaining why you made changes:

Test After Changes

Always test your app after modifying Metro config:

Version Control

Commit your metro.config.js:

Advanced Features

Custom Serializer

Modify the bundle output:
metro.config.js

Plugin System

Use Metro plugins:
metro.config.js

Resources