Gathering detailed insights and metrics for react-native-react-bridge
Gathering detailed insights and metrics for react-native-react-bridge
Gathering detailed insights and metrics for react-native-react-bridge
Gathering detailed insights and metrics for react-native-react-bridge
@applicaster/zapp-react-native-bridge
Applicaster Zapp React Native modules
@unimodules/react-native-adapter
The adapter to use universal modules with the React Native bridge
react-native-share
Social share, sending simple data to other apps.
@contentsquare/react-native-bridge
A JavaScript bridge to the native iOS and Android Contentsquare SDKs, for React Native apps.
An easy way to integrate your React (or Preact/React Native Web) app into React Native app with WebView.
npm install react-native-react-bridge
Typescript
Module System
Node Version
NPM Version
TypeScript (49.16%)
CSS (28.34%)
JavaScript (17.69%)
HTML (4.81%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
281 Stars
415 Commits
25 Forks
3 Watchers
13 Branches
6 Contributors
Updated on Jun 24, 2025
Latest Version
0.12.4
Package Id
react-native-react-bridge@0.12.4
Unpacked Size
50.96 kB
Size
11.15 kB
File Count
28
NPM Version
10.7.0
Node Version
22.2.0
Published on
Mar 04, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
3
22
An easy way to integrate your React (or Preact/React Native Web) app into React Native app with WebView.
[!NOTE] You may also like Expo DOM components
If you'd like to run your React web app in React Native, rewriting it for React Native or using react-native-web is preferred way in most cases. But sometimes rewriting is overkill, when you are just prototyping, or when the app includes something not available on React Native, like rich text editor with contenteditable or complicated logic with WebAssembly.
So how we run React app in React Native app as it is? It's logically possible if you run your web code in WebView using react-native-webview. However bundling React code with React Native is troublesome and implementing communication between React Native and WebView is so hard.
This library gives a bridge to make it easy. This will bundle the whole React app by some additional codes and it will be automatically re-compiled if you edit it. You rarely need to think which code you are editing for React or React Native, like isomorphic. The communication between React app and React Native app will be also simplified by this.
useWebViewMessage
hook, you can subscribe messages from WebView.useNativeMessage
hook, you can subscribe messages from React Native.emit
function sends message..json
is imported as an object, like require in Node.js..txt
and .md
are imported as string, like raw-loader..css
is injected to the HTML head of WebView, like css-loader with style-loader..bmp
, .gif
, .png
, .jpg
, .jpeg
, .webp
and .svg
are loaded as base64 encoded url, like url-loader..htm
and .html
are loaded as string, which can be rendered with React's dangerouslySetInnerHTML..wasm
is imported like Node.js, which is compatible with ES Module Integration Proposal for WebAssembly.If you have some feature requests or improvements, please create a issue or PR.
1npm install react-native-react-bridge react-native-webview 2 3# Necessary only if you render React app in WebView 4npm install react-dom 5 6# Necessary only if you render Preact app in WebView 7# preact >= 10.0 8npm install preact 9 10# Necessary only if you render React Native Web app in WebView 11npm install react-dom react-native-web
metro.config.js
to use babelTransformer from this library.1module.exports = { 2 transformer: { 3 // This detects entry points of React app and transforms them 4 // For the other files this will switch to use default `metro-react-native-babel-transformer` for transforming 5 babelTransformerPath: require.resolve('react-native-react-bridge/lib/plugin'), 6 ... 7 }, 8/* 9 // optional config 10 rnrb: { 11 // Set `true` if you use Preact in web side. 12 // This will alias imports from `react` and `react-dom` to `preact/compat` automatically. 13 preact: true, 14 // Set `true` if you use react-native-web in web side. 15 // This will alias imports from `react-native` to `react-native-web` automatically. 16 web: true 17 }, 18*/ 19 ... 20};
1const { getDefaultConfig } = require("expo/metro-config"); 2 3const config = getDefaultConfig(__dirname); 4 5config.transformer.babelTransformerPath = require.resolve( 6 "react-native-react-bridge/lib/plugin" 7); 8 9module.exports = config;
If your project at some point requires a metro configuration with additional transformers, consider making a separate customTransformer.js
file in the project root with logic for delegating files types to the appropriate transformer, and modifying metro.config.js
file to reference the customer transformer file. For example, if you are using react-native-svg-transformer
, this would be your custom transformer file:
1// root/customTransformer.js 2const reactNativeReactBridgeTransformer = require("react-native-react-bridge/lib/plugin"); 3const svgTransformer = require("react-native-svg-transformer"); 4 5module.exports.transform = function ({ src, filename, options }) { 6 if (filename.endsWith(".svg")) { 7 return svgTransformer.transform({ src, filename, options }); 8 } else { 9 return reactNativeReactBridgeTransformer.transform({ 10 src, 11 filename, 12 options, 13 }); 14 } 15};
And this would be your metro config:
1// root/metro.config.js 2const { getDefaultConfig } = require("metro-config"); 3 4module.exports = (async () => { 5 const { 6 resolver: { sourceExts, assetExts }, 7 } = await getDefaultConfig(); 8 return { 9 transformer: { 10 babelTransformerPath: require.resolve("./customTransformer.js"), 11 }, 12 resolver: { 13 assetExts: assetExts.filter((ext) => ext !== "svg"), 14 sourceExts: [...sourceExts, "svg"], 15 }, 16 }; 17})();
To support custom Esbuild options, we can use Multiple Transformers method and replace the customTransformer.js file with the following code:
1// root/customTransformer.js 2const reactNativeReactBridgeTransformer = require("react-native-react-bridge/lib/plugin"); 3 4const esbuildOptions = { 5 pluglins: [], 6}; 7const transform = 8 reactNativeReactBridgeTransformer.createTransformer(esbuildOptions); 9 10module.exports.transform = function ({ src, filename, options }) { 11 return transform({ src, filename, options }); 12};
react-native-react-bridge/lib/web
.react-native-react-bridge/lib/web/preact
.1// WebApp.js 2 3import React, { useState } from "react"; 4import { 5 webViewRender, 6 emit, 7 useNativeMessage, 8} from "react-native-react-bridge/lib/web"; 9// Importing css is supported 10import "./example.css"; 11// Images are loaded as base64 encoded string 12import image from "./foo.png"; 13 14const Root = () => { 15 const [data, setData] = useState(""); 16 // useNativeMessage hook receives message from React Native 17 useNativeMessage((message) => { 18 if (message.type === "success") { 19 setData(message.data); 20 } 21 }); 22 return ( 23 <div> 24 <img src={image} /> 25 <div>{data}</div> 26 <button 27 onClick={() => { 28 // emit sends message to React Native 29 // type: event name 30 // data: some data which will be serialized by JSON.stringify 31 emit({ type: "hello", data: 123 }); 32 }} 33 /> 34 </div> 35 ); 36}; 37 38// This statement is detected by babelTransformer as an entry point 39// All dependencies are resolved, compressed and stringified into one file 40export default webViewRender(<Root />);
1// App.js 2 3import React from "react"; 4import WebView from "react-native-webview"; 5import { useWebViewMessage } from "react-native-react-bridge"; 6import webApp from "./WebApp"; 7 8const App = () => { 9 // useWebViewMessage hook create props for WebView and handle communication 10 // The argument is callback to receive message from React 11 const { ref, onMessage, emit } = useWebViewMessage((message) => { 12 // emit sends message to React 13 // type: event name 14 // data: some data which will be serialized by JSON.stringify 15 if (message.type === "hello" && message.data === 123) { 16 emit({ type: "success", data: "succeeded!" }); 17 } 18 }); 19 20 return ( 21 <WebView 22 // ref, source and onMessage must be passed to react-native-webview 23 ref={ref} 24 // Pass the source code of React app 25 source={{ html: webApp }} 26 onMessage={onMessage} 27 /> 28 ); 29};
react-native-webview has some ways to show errors occurred in webview. This may be helpful to troubleshoot it.
https://github.com/react-native-webview/react-native-webview/blob/master/docs/Reference.md#onerror
This repository includes demo app.
1git clone git@github.com:inokawa/react-native-react-bridge.git 2cd examples/DemoApp 3npm install 4npm run ios # or npm run android
All contributions are welcome. If you find a problem, feel free to create an issue or a PR.
npm install
.No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
binaries present in source code
Details
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
Found 4/22 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
28 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More