WebView

Also known as: Android WebView · WKWebView

On this page 7

A WebView is a native UI component that embeds a browser engine inside an app, so the app can render HTML, CSS and JavaScript within its own screens. In the mobile web, it is the bridge between native code and web content: on Android it is the Android WebView based on Chromium, and on iOS it is WKWebView based on WebKit.

Unlike a full mobile browser, a WebView has no address bar, tabs or browser chrome by default. The host app decides what loads, how navigation behaves and which native capabilities, if any, are exposed to the page.

How a WebView renders content inside an app

A WebView works by hosting a rendering engine in the app’s view hierarchy. The app creates the view, configures settings such as JavaScript support, and loads either a remote URL, a local file or an HTML string supplied by native code.

On modern platforms the engine runs largely out of process. WKWebView renders content in separate WebKit processes, and Android WebView uses a separate renderer process on current versions, which improves stability: a crashing page should not take the whole app down, although the app must handle the render process termination callback correctly.

The engine is updated independently of the app. Android WebView is delivered through Google Play as a system component, while WKWebView is updated with iOS releases. Web features available to an app therefore depend on the user’s system version, not on the app build.

PlatformComponentEngineUpdate path
AndroidAndroid WebViewChromium (Blink, V8)Google Play system updates
iOS and iPadOSWKWebViewWebKit (JavaScriptCore)Operating system updates
Legacy iOSUIWebViewOlder WebKit, in processDeprecated and rejected by App Store
Cross-platform frameworksWrappers over the native viewInherited from the platformSame as underlying platform
Platform implementations of WebView

The JavaScript bridge and native integration

The defining capability of a WebView is the JavaScript bridge: a channel that lets page scripts call native code and lets native code inject or evaluate scripts. This is what hybrid frameworks use to give web code access to the camera, storage, push notifications or payments.

DirectionAndroidiOS
Web to nativeaddJavascriptInterface or WebMessageListenerWKScriptMessageHandler via postMessage
Native to webevaluateJavascriptevaluateJavaScript
Script injection at loadDocument start scripts via AndroidX WebKitWKUserScript at document start or end
Navigation controlshouldOverrideUrlLoadingdecidePolicyFor navigation delegate
Common bridge mechanisms

Every bridge method is an attack surface. If a WebView loads untrusted or third-party content while exposing powerful native methods, any script on that page may invoke them, so bridges should be restricted to trusted origins and validate every message.

A WebView is the most flexible option for showing web content in an app, but it is not the right choice for every link. Platform vendors provide browser-based alternatives that share cookies and saved passwords with the user’s browser and keep the page isolated from the app.

ComponentApp control over pageShares browser sessionTypical use
WebViewFull, including script injectionNo, separate cookie storeHybrid app screens, embedded content
Custom TabsLimited to toolbar stylingYes, with the default browserOpening external links on Android
SFSafariViewControllerLimited to tint and controlsPartially, with Safari featuresOpening external links on iOS
Trusted Web ActivityNone inside the pageYes, full browserShipping a PWA as an Android app
Mobile browserNoneYesGeneral browsing
WebView versus in-app browser alternatives

For sign-in flows, OAuth providers and security guidance recommend the browser-based components rather than a WebView, because a WebView lets the host app observe or alter credentials typed into the page.

Configuring a WebView for production

A production WebView needs explicit configuration, because defaults are tuned for compatibility rather than security or performance. The most important decisions concern what content loads and what the page is allowed to do.

  • Allowlist origins: intercept navigation and open unknown domains in the system browser or Custom Tabs.
  • Disable file access unless needed, especially universal access from file URLs on Android.
  • Enable JavaScript only when required and expose the smallest possible bridge.
  • Serve local assets safely with WebViewAssetLoader on Android or a custom URL scheme handler on iOS instead of raw file URLs.
  • Handle lifecycle events: pause timers in the background and recreate the view after render process termination.
  • Set a correct viewport meta tag and test dynamic viewport units, safe areas and the on-screen keyboard.

Debugging is done with remote inspection tools: Chrome DevTools for Android WebView and Safari Web Inspector for WKWebView, which on recent iOS versions requires setting the view as inspectable in debug builds.

Limitations and common mistakes

WebView-based screens often feel less responsive than native views, especially on lower-end Android devices, because of JavaScript execution, layout cost and the overhead of crossing the bridge. Performance problems usually come from heavy pages rather than from the component itself.

SymptomLikely causeFix
Blank screen after resumeRender process was killedHandle termination and reload the view
Login state lostSeparate cookie store from the browserUse Custom Tabs or sync cookies deliberately
Feature works in browser, not in appOlder system engine or disabled settingFeature-detect and enable needed settings
Arbitrary native calls from adsBridge exposed to untrusted originsRestrict bridge by origin and validate messages
Keyboard hides input fieldsViewport and resize behavior not configuredAdjust window resize mode and test viewport units
Typical problems and fixes

Store policies also apply. Apple guidelines discourage apps that are merely a repackaged website with no native value, so a thin WebView wrapper may face rejection during App Review.

The idea in brief

A WebView is a small browser window built into an app. It shows web pages, but without the usual address bar or tabs, so the page looks like part of the app itself.

Think of it as a picture frame the app owner controls: they choose what goes in the frame and can even reach into it. That is useful for showing content, but it also means the app can see what happens inside the frame, which is why sensitive logins usually open in the real browser instead.

A practical scenario

A regional bank’s mobile team keeps its frequently changing product pages and help center on the web, while account balances and transfers remain native. The app shows the help center in a WebView restricted to the bank’s own domain, injects the user’s preferred language through a document start script and exposes a single bridge method that opens the native chat screen.

External links, such as partner insurance offers, open in Custom Tabs on Android and SFSafariViewController on iOS. The result is that help content updates without an app release, the bridge cannot be reached from third-party pages, and the bank passes its security review because no credentials are ever entered inside the WebView.