react-native-minimal-webview¶
A React Native WebView that hands you the iOS and Android WebView APIs, instead of wrapping each one in a prop.
It runs on iOS and Android as an Expo module.
Get started · Examples · API reference · Migrating from react-native-webview
Why it exists¶
react-native-webview wraps each platform API in a prop of its own. When one isn't wrapped, you wait for an upstream PR, or patch or fork the package, even if the change is one platform call.
This package passes the platform APIs through instead:
iosandandroidprops: any setting, by its platform name.- The ref's
getandcall: properties and methods, by name. - Native hooks: the
WKWebVieworWebViewitself, in your own Swift or Kotlin module.
import { useRef } from 'react';
import { Button, Platform } from 'react-native';
import { WebView, type WebViewRef } from 'react-native-minimal-webview';
export function Browser() {
const ref = useRef<WebViewRef>(null);
const pageDown = () => {
// Android's WebView.pageDown(boolean): a method string names one platform's method
if (Platform.OS === 'android') ref.current?.call('webView.pageDown', [true]);
};
return (
<>
<Button title="Page down" onPress={pageDown} />
<WebView
ref={ref}
source={{ uri: 'https://example.com' }}
style={{ flex: 1 }}
ios={{ scrollView: { bounces: false } }}
android={{ settings: { textZoom: 120 } }}
/>
</>
);
}
A setting a newer SDK adds goes under its root's other key, and call takes any public method, so neither waits for a
release of this package: see
ios,
android and
call.
What the core adds¶
How it works explains the parts. The core adds only what the platform APIs lack:
navigationRules: navigations decided natively, with a JS round trip only where a prop asks for one.- A typed promise bridge (
createBridge):window.nativeBridgein the page, open only to the bridge'sallowedOrigins. useWebViewState(ref): the navigation state, kept natively.onPermissionRequest: your app answers the page's permission requests (camera, microphone, location).
The migration guide covers each react-native-webview prop that works differently here.
When to use something else¶
- Old architecture, Windows or macOS: react-native-webview supports them, this package doesn't. Neither runs on web.
- Expo Go: the package has native code, so it needs a development build.
Install¶
Get started walks you through a new Expo app with a WebView on screen.
In an Expo app, install the package and expo-build-properties:
Set the iOS and Android minimums in app.json, before you rebuild: below iOS 17.0, the build leaves
the package's native module out, and WebView throws as it renders.
{
"expo": {
"plugins": [
[
"expo-build-properties",
{ "ios": { "deploymentTarget": "17.0" }, "android": { "minSdkVersion": 29 } }
]
]
}
}
Then rebuild the app (npx expo run:ios, npx expo run:android).
A bare React Native app adds Expo modules first, then installs with its package manager. It sets the minimums in
ios/Podfile (platform :ios, '17.0') and android/build.gradle (minSdkVersion = 29) before pod-install:
npx install-expo-modules@latest
npm install react-native-minimal-webview # or: yarn add, pnpm add
npx pod-install
Requirements¶
| Platform | Minimum |
|---|---|
| iOS | 17.0 |
| Android | API 29 |
| Expo SDK | 53 (React Native 0.79, React 19) |
| Architecture | New architecture only |
Some features need a newer Android System WebView: which ones.
Usage¶
Pick what you need:
| To | See |
|---|---|
| Show the URL, progress or a back button | Navigation state |
| Show a spinner and your own error screen | Loading and error screens |
| Keep the WebView on your sites, open the rest externally | Navigation rules |
| Call the page from the app, and the app from the page | The bridge |
| Change a WebView setting, or call a platform method | Use a platform API |
| Share cookies with native requests | Cookies |
| Run a script on every page | Scripts |
| Load bundled HTML | Local files |
| Answer file pickers, permissions and downloads | Page requests |
| Inspect the page's DOM and console | Debugging the page |
Use the native WKWebView or WebView |
Native hooks |
Bring back basicAuthCredential, onScroll and other react-native-webview props |
@react-native-minimal-webview/extensions |
| Find out why something doesn't work | Troubleshooting |
Contributing¶
CONTRIBUTING.md has the setup, the checks and the on-device suites.