diff --git a/docs/platforms/react-native/manual-setup/metro.mdx b/docs/platforms/react-native/manual-setup/metro.mdx index 9e49a5dfcdbc45..660baf0a73dc21 100644 --- a/docs/platforms/react-native/manual-setup/metro.mdx +++ b/docs/platforms/react-native/manual-setup/metro.mdx @@ -72,6 +72,37 @@ const config = getSentryExpoConfig(__dirname, { }); ``` +### Reduce Bundle Size + +If you're not using the Session Replay or User Feedback features, you can exclude their web-only packages from the bundle by opting out via the Metro Plugin options. When set to `false`, the Sentry Metro Plugin resolves the matching Sentry sub-packages to an empty module so they're not included in the output bundle. + +| Option | Default | Effect when set to `false` | +| ------------------ | ------- | ------------------------------------------------------------------------ | +| `includeWebReplay` | `true` | Excludes `@sentry/replay` and `@sentry-internal/replay` from the bundle. | +| `includeFeedback` | `true` | Excludes `@sentry-internal/feedback` from the bundle. | + +Note that these options only affect bundling. They do not disable the corresponding native (Android/iOS) integrations. + +```javascript {tabTitle:React Native} {filename:metro.config.js} +const { getDefaultConfig } = require("@react-native/metro-config"); +const { withSentryConfig } = require("@sentry/react-native/metro"); + +const config = getDefaultConfig(__dirname); +module.exports = withSentryConfig(config, { + includeWebReplay: false, + includeFeedback: false, +}); +``` + +```javascript {tabTitle:Expo} {filename:metro.config.js} +const { getSentryExpoConfig } = require("@sentry/react-native/metro"); + +const config = getSentryExpoConfig(__dirname, { + includeWebReplay: false, + includeFeedback: false, +}); +``` + ### Wrap Your Custom Serializer If you already have a custom serializer, you can wrap it with the Sentry Metro Serializer and call `options.sentryBundleCallback` before serializing the bundle content.