🚇 The JavaScript bundler for React Native.
- 🚅 Fast: We aim for sub-second reload cycles, fast startup and quick bundling speeds.
- ⚖️ Scalable: Works with thousands of modules in a single application.
- ⚛️ Integrated: Supports every React Native project out of the box.
Metro is included with React Native — see the React Native docs to quickly get started ⏱️.
To add Metro to an existing project, see our Getting Started guide.
All available documentation, including on configuring Metro, can be found on the Metro website.
Source code for documentation is located in this repository under docs/.
Metro was previously part of the react-native repository. In this standalone repository it is easier for the team working on Metro to respond to issues and pull requests. See react-native#13976 for the initial announcement.
Meta has adopted a Code of Conduct that we expect project participants to adhere to. Please read the full text so that you can understand what actions will and will not be tolerated.
Read our contributing guide to learn about our development process, how to propose bug fixes and improvements, and how to build and test your changes to Metro.
Larger discussions and proposals concerning React Native and Metro are discussed in @react-native-community/discussions-and-proposals.
Metro is MIT licensed, as found in the LICENSE file.
This is exploritory functionalityby @codepilots. It may or may not work, use at your own risk!
This fork adds robust support for running Metro behind a reverse proxy by introducing a configurable baseUrl option. All URLs and file paths served by the Metro server—including bundles, source maps, HMR, delta, assets, symbolicate, and all other endpoints—are now correctly prefixed with the configured baseUrl. This ensures Metro can be hosted at a non-root path and all outgoing URLs and endpoint routing will work as expected.
- Configurable
baseUrl: The server reads abaseUrlfrom the config and uses it to prefix all served URLs and endpoint matches. - Endpoint Routing: All endpoint handlers in
Server.jsuse utilities to strip or add thebaseUrlfor correct internal routing and external URL generation. - Outgoing URLs: All outgoing URLs in responses (such as asset metadata, bundle URLs, source maps, and module source URLs in source maps and error stacks) are generated with the
baseUrlprefix. - Asset Metadata: The
.assetsendpoint and asset metadata now use the baseUrl-prefixed/assetsas theirpublicPath. - Source Maps: Module source URLs in source maps are baseUrl-prefixed when using server-relative paths.
- HMR and Async Split Bundles: All dynamic bundle URLs are constructed with the
baseUrl.
- Added
_prefixWithBaseUrland_stripBaseUrlutilities inServer.jsfor consistent path handling. - Updated all endpoint routing and outgoing URL generation to use these utilities.
- Ensured asset metadata and module source URLs are always baseUrl-aware.
- Updated HMR and async split bundle URL construction to use
baseUrl. - All changes are Flow-typed and maintain compatibility with the existing Metro codebase.
To use Metro behind a reverse proxy, set the baseUrl option in your Metro config:
// metro.config.js
module.exports = {
baseUrl: '/my/proxy/path',
// ...other config
};All served URLs and endpoint routing will now respect this baseUrl.