@datadog/mobile-react-native-webview

中文文档
3.11.0发布于 2026/10/20Apache-2.0TypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 17.3万

A client-side React Native module to interact with react-native-webview and Datadog

原始使用文档
文档目录5 节
  1. Overview
  2. Setup
  3. Prerequisites
  4. Instrument your web views
  5. Access your web views

React-Native Monitoring for react-native-webview

Overview

Real User Monitoring (RUM) allows you to monitor web views and eliminate blind spots in your hybrid React Native applications.

You can perform the following:

  • Track user journeys across web and native components in mobile applications
  • Scope the root cause of latency to web pages or native components in mobile applications
  • Support users that have difficulty loading web pages on mobile devices

RUM supports web views created using react-native-webview.

Setup

Prerequisites

Set up the RUM Browser SDK on the web page you want rendered on your mobile React Native application. For more information, see RUM Browser Monitoring.

Add react-native-webview to your application following the official installation documentation.

Instrument your web views

Import WebView from @datadog/mobile-react-native-webview instead of react-native-webview:

import { WebView } from '@datadog/mobile-react-native-webview';
// or
import WebView from '@datadog/mobile-react-native-webview';

You can use all existing functionalities from react-native-webview as the WebView component from @datadog/mobile-react-native-webview wraps the react-native-webview component.

Provide the list of hosts to be tracked by Datadog inside the web view by using the allowedHosts prop of your WebView component:

<WebView
    source={{ uri: 'https://www.example.com' }}
    allowedHosts={['example.com']}
/>

Access your web views

Your web views appear in the RUM Explorer with associated service and source attributes. The service attribute indicates the web component the web view is generated from, and the source attribute denotes the mobile application's platform, such as React Native.

Filter on your React Native applications, and click a session. A side panel with a list of events in the session appears.

{{< img src="real_user_monitoring/react_native/reactnative_webview_session.png" alt="webview session example" >}}

Click Open View waterfall to navigate from the session to a resource waterfall visualization in the view's Performance tab.

版本与发布记录

@datadog/mobile-react-native-webview 共发布 94 个版本,首次发布于 2023/04/04;过去 12 个月发布了 32 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
3.11.0latest2026/10/2021 天前
3.10.02026/10/091 个月前
3.9.02026/10/011 个月前
3.8.02026/09/221 个月前
3.7.02026/09/032 个月前
3.6.02026/08/172 个月前

其他发布通道:next → 2.0.0-rc.0,v2 → 2.14.9。

关于 @datadog/mobile-react-native-webview 的常见问题

@datadog/mobile-react-native-webview 是什么?

A client-side React Native module to interact with react-native-webview and Datadog

如何安装 @datadog/mobile-react-native-webview?

在项目目录运行 npm install @datadog/mobile-react-native-webview,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=16.13.1)、react-native(>=0.63.4 <1.0)、react-native-webview(>=11.0.0)、@datadog/mobile-react-native(^3.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@datadog/mobile-react-native-webview 支持 TypeScript 吗?

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

@datadog/mobile-react-native-webview 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@datadog/mobile-react-native-webview 可以商用吗?

@datadog/mobile-react-native-webview 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@datadog/mobile-react-native-webview 的下载量有多少?

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

@datadog/mobile-react-native-webview 还在维护吗?

最新版本 3.11.0 发布于 2026/10/20(21 天前);至今共发布 94 个版本,其中过去 12 个月发布了 32 个;首次发布于 2023/04/04。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。