Skip to content
Documentation for 0.2.0. Check your installed version and the migration guide.

Props ​

NitroWebView accepts React Native view layout props and the WebView props below. Wrap all event and hybrid-ref callbacks with callback().

Content and settings ​

PropTypeBehavior
sourceWebViewSourceURI or inline HTML. Required.
defaultHeadersRecord<string, string>Source-initiated headers; source headers win case-insensitively.
userAgentstringOverrides the UA for all WebView requests. Empty restores the default.
javaScriptEnabledbooleanDefault true. Android mutable; iOS initial-only.
domStorageEnabledbooleanDefault true. Android only; iOS always enables DOM storage.
cacheEnabledbooleanAndroid cache mode; iOS policy on the next source load.
incognitobooleanDefault false. iOS separate ephemeral store; Android rejects true.
sharedCookiesEnabledbooleanDefault false. iOS one-time app-cookie import before the first load.
thirdPartyCookiesEnabledbooleanAndroid per-view third-party cookie policy; iOS ignores it.
scrollEnabledbooleanDefault true. iOS only; Android no-op.
bouncesbooleanDefault true. iOS only; Android no-op.
scalesPageToFitbooleanDefault false. Android overview and wide viewport; iOS no-op.
allowsBackForwardNavigationGesturesbooleanDefault false. iOS history swipes; Android no-op.
mediaPlaybackRequiresUserActionbooleanDefault true. iOS initial-only; Android mutable.
allowsInlineMediaPlaybackbooleanDefault false on iOS; needs HTML playsinline. Android already inline.
injectedJavaScriptstringDocument-end injection on page loads.
injectedJavaScriptBeforeContentLoadedstringMain-frame start injection; older Android WebViews have a timing fallback.
allowedMessageOriginsstring[]Exact HTTP(S) origins. Omitted allows all; [] denies all.
mediaCapturePermissionOriginsstring[]Android camera/microphone origins. Default denies all.
geolocationPermissionOriginsstring[]Android location origins. Default denies all.
interceptSubframeNavigationbooleanDefault false. Android iframe interception opt-in; iOS ignores it.

Callbacks and refs ​

hybridRef receives NitroWebViewType. The normal React ref is a host ref. Call methods through the hybrid ref.

CallbackArgumentBehavior
onLoadStartWebViewLoadEventMain-document loading begins.
onLoadWebViewLoadEventSuccessful completion only, before onLoadEnd.
onLoadProgressWebViewLoadProgressEventEstimate in nativeEvent.progress, from 0 to 1.
onLoadEndWebViewLoadEventTerminal event, including failed loads.
onNavigationStateChangeWebViewNavigationStateDirect state, without a nativeEvent wrapper. Includes SPA history.
onMessageWebViewMessageEventPage string and available native sender information.
onErrorNitroWebViewErrorEventTransport, configuration, source, or blob errors; inspect domain.
onHttpErrorNitroWebViewHttpErrorEventMain-frame HTTP 4xx/5xx, not subresources.
onFileDownloadFileDownloadEventHTTP metadata or a resolved platform-specific blob reference.
onOpenWindowOpenWindowEventNew-window destination; notify-only. Suppresses the in-place fallback.
onRenderProcessGoneNitroWebViewRenderProcessGoneEventAndroid API 26+ destroys this view; iOS supports reload.
onScrollNitroWebViewScrollEventUnthrottled scroll stream. Geometry differs by platform.
onShouldStartLoadWithRequestShouldStartLoadRequestReturns boolean or Promise<boolean>. Check platform timing and coverage.

Initial settings ​

On iOS, incognito, sharedCookiesEnabled, javaScriptEnabled, mediaPlaybackRequiresUserAction, and allowsInlineMediaPlayback apply before the first load. Remount with a new React key to change them.

Read navigation, messaging, and platform differences for restrictions.

MIT licensed · Built with Nitro Modules