@rozenite/metro
v1.2.0
Published
Metro bundler plugin for Rozenite.
Maintainers
Readme

A Metro bundler plugin for integrating React Native DevTools plugins into your development workflow.
The Rozenite Metro plugin seamlessly integrates custom DevTools plugins into your React Native development environment. It automatically discovers installed plugins, serves them through Metro's development server, and provides the necessary infrastructure for plugin communication and UI rendering.
Features
- Automatic Plugin Discovery: Automatically finds and loads installed Rozenite plugins from node_modules
- Metro Integration: Seamlessly integrates with Metro bundler's middleware system
- Plugin Serving: Serves plugin assets and panels through Metro's development server
- DevTools Frontend Integration: Patches React Native DevTools frontend for plugin support
- Express Middleware: Provides custom Express middleware for plugin routing and serving
- Configuration Options: Flexible configuration for including/excluding specific plugins
Installation
Install the Metro plugin as a development dependency:
npm install --save-dev @rozenite/metroQuick Start
Basic Setup
Add the Rozenite plugin to your Metro configuration:
// metro.config.js
import { withRozenite } from '@rozenite/metro';
export default withRozenite({
// Your existing Metro configuration
});With Custom Options
Configure plugin discovery and filtering:
// metro.config.js
import { withRozenite } from '@rozenite/metro';
export default withRozenite(
{
// Your existing Metro configuration
},
{
include: ['@my-org/my-plugin', 'another-plugin'],
exclude: ['unwanted-plugin'],
destroyOnDetachPlugins: ['@rozenite/network-activity-plugin'],
}
);Configuration
RozeniteMetroConfig
The configuration object for the Metro plugin:
type RozeniteMetroConfig = {
include?: string[]; // Only load these specific plugins
exclude?: string[]; // Exclude these plugins from loading
destroyOnDetachPlugins?: string[]; // Plugins that should be destroyed when switching panels
};Options:
include- Array of package names to explicitly include (optional)exclude- Array of package names to exclude from loading (optional)destroyOnDetachPlugins- Array of package names that should be destroyed when switching panels instead of maintaining their state (optional, by default all plugins persist their state)
Plugin Discovery
The Metro plugin automatically discovers Rozenite plugins by:
- Scanning node_modules: Searches all node_modules directories in the project
- Checking for Rozenite manifest: Looks for the Rozenite manifest file in each package
- Validating plugin structure: Ensures the plugin has the required build output
- Loading plugin metadata: Extracts plugin information for integration
Development Workflow
- Install plugins in your React Native project
- Configure Metro with the Rozenite plugin
- Start Metro server - plugins are automatically discovered and loaded
- Access DevTools - plugins appear in the React Native DevTools interface
- Develop plugins - use hot reload for plugin development
Plugin Requirements
For a package to be recognized as a Rozenite plugin, it must:
- Have a Rozenite manifest:
dist/rozenite.jsonfile - Be properly built: Plugin assets must be available in the
distdirectory - Follow naming conventions: Package name should not start with
. - Be accessible: Package must be readable from node_modules
Troubleshooting
No plugins found
- Ensure plugins are properly installed in
node_modules - Check that plugins have been built and contain
dist/rozenite.json - Verify plugin package names are not excluded in configuration
Plugin not loading
- Check Metro server logs for plugin discovery messages
- Verify plugin manifest file exists and is valid
- Ensure plugin assets are properly built and accessible
Middleware conflicts
- The Rozenite middleware is designed to work alongside existing Metro middleware
- Custom middleware is preserved and enhanced, not replaced
- Check for conflicts with other Metro plugins
Requirements
- Node.js >= 22
- Metro bundler
- React Native project
- Installed Rozenite plugins
Made with ❤️ at Callstack
rozenite is an open source project and will always remain free to use. If you think it's cool, please star it 🌟.
Callstack is a group of React and React Native geeks, contact us at [email protected] if you need any help with these or just want to say hi!
Like the project? ⚛️ Join the team who does amazing stuff for clients and drives React Native Open Source! 🔥
