@config-plugins/react-native-webrtc

中文文档
15.0.2发布于 2026/08/15MITTypeScriptCommonJS零依赖近 30 天下载 237.6万

Config plugin to setup react-native-webrtc on prebuild

原始使用文档
文档目录6 节
  1. Versioning
  2. Expo installation
  3. Event Target Shim
  4. API
  5. Important Notes
  6. Manual Setup

config-plugins/react-native-webrtc

Config plugin to auto-configure react-native-webrtc when the native code is generated (npx expo prebuild). Upstream PR.

Versioning

Ensure you use versions that work together!

exporeact-native-webrtc@config-plugins/react-native-webrtc
56.0.0124.0.715.0.0
55.0.0124.0.714.0.0
54.0.0124.0.613.0.0
53.0.0124.0.512.0.0
52.0.0124.0.410.0.0
51.0.0118.0.79.0.0
50.0.0118.0.18.0.0
49.0.0111.0.37.0.0
48.0.0106.0.66.0.0
47.0.01.106.15.0.0
46.0.01.100.04.0.0
45.0.01.100.03.0.0
44.0.01.92.22.0.0
43.0.01.92.21.0.0

Expo SDK 42 uses [email protected] which doesn't work with react-native-webrtc, specifically iOS production builds fail. Meaning this package is only supported for Expo SDK +43.

Expo installation

This package cannot be used in the "Expo Go" app because it requires custom native code. First install the package with yarn, npm, or npx expo install.

npx expo install react-native-webrtc @config-plugins/react-native-webrtc

After installing this npm package, add the config plugin to the plugins array of your app.json or app.config.js:

{
  "plugins": ["@config-plugins/react-native-webrtc"]
}

Next, rebuild your app as described in the "Adding custom native code" guide.

Event Target Shim

Only for SDK 50.

React Native uses event-target-shim@5 which is not compatible with react-native-webrtc's dependency on event-target-shim@6. To fix this, you may need to add a redirection in your metro.config.js file:

// metro.config.js

// Learn more https://docs.expo.io/guides/customizing-metro
const { getDefaultConfig } = require("expo/metro-config");
const resolveFrom = require("resolve-from");

/** @type {import('expo/metro-config').MetroConfig} */
const config = getDefaultConfig(__dirname);

config.resolver.resolveRequest = (context, moduleName, platform) => {
  if (
    // If the bundle is resolving "event-target-shim" from a module that is part of "react-native-webrtc".
    moduleName.startsWith("event-target-shim") &&
    context.originModulePath.includes("react-native-webrtc")
  ) {
    // Resolve event-target-shim relative to the react-native-webrtc package to use v6.
    // React Native requires v5 which is not compatible with react-native-webrtc.
    const eventTargetShimPath = resolveFrom(
      context.originModulePath,
      moduleName
    );

    return {
      filePath: eventTargetShimPath,
      type: "sourceFile",
    };
  }

  // Ensure you call the default resolver.
  return context.resolveRequest(context, moduleName, platform);
};

module.exports = config;

API

The plugin provides props for extra customization. Every time you change the props or plugins, you'll need to rebuild (and prebuild) the native app. If no extra properties are added, defaults will be used.

  • cameraPermission (string): Sets the iOS NSCameraUsageDescription permission message to the Info.plist. Defaults to Allow $(PRODUCT_NAME) to access your camera.
  • microphonePermission (string): Sets the iOS NSMicrophoneUsageDescription permission message to the Info.plist. Defaults to Allow $(PRODUCT_NAME) to access your microphone.

app.config.js

export default {
  plugins: [
    [
      "@config-plugins/react-native-webrtc",
      {
        cameraPermission: "Allow $(PRODUCT_NAME) to access your camera",
        microphonePermission: "Allow $(PRODUCT_NAME) to access your microphone",
      },
    ],
  ],
};

Important Notes

  • For iOS, this plugin disables Bitcodes for all builds (required).
  • For Android, this plugin disables desugaring in gradle.properties: android.enableDexingArtifactTransform.desugaring=false and the minimum deployment target is changed to 24 (from 21) which may break other packages in your app!

Manual Setup

For bare workflow projects, you can follow the manual setup guides:

版本与发布记录

@config-plugins/react-native-webrtc 共发布 22 个版本,首次发布于 2021/06/25;过去 12 个月发布了 4 个版本。

版本发布日期距今
15.0.2latest2026/08/152 个月前
15.0.12026/06/045 个月前
15.0.02026/06/035 个月前
14.0.02026/04/107 个月前
13.0.02025/09/241.1 年前
12.0.02025/06/031.4 年前

关于 @config-plugins/react-native-webrtc 的常见问题

@config-plugins/react-native-webrtc 是什么?

Config plugin to setup react-native-webrtc on prebuild

如何安装 @config-plugins/react-native-webrtc?

在项目目录运行 npm install @config-plugins/react-native-webrtc,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:expo(>=56)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@config-plugins/react-native-webrtc 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@config-plugins/react-native-webrtc 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@config-plugins/react-native-webrtc 可以商用吗?

@config-plugins/react-native-webrtc 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@config-plugins/react-native-webrtc 的下载量有多少?

根据 npm 官方下载统计,@config-plugins/react-native-webrtc 在 2026/10/11 – 2026/11/09 这 30 天内被下载 2,375,715 次,日均约 79,191 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@config-plugins/react-native-webrtc 还在维护吗?

最新版本 15.0.2 发布于 2026/08/15(2 个月前);至今共发布 22 个版本,其中过去 12 个月发布了 4 个;首次发布于 2021/06/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。