swiftui-webview
SwiftUI WebView
Displaying and controlling web content in SwiftUI. The deep API reference — native WebView/WebPage, navigation events, NavigationDeciding, JS interaction, URLSchemeHandler, find-in-page, the WKWebView/UIViewRepresentable path, coordinator pattern, and migration — lives in references/guide.md. This file is the decision and discipline layer: read it first, open the guide for specifics.
Dials
Set these explicitly at the start; they change what "correct" means.
BACKEND—native(iOS 26+ SwiftUIWebView+WebPage, default; no UIKit) ·representable(WKWebViewviaUIViewRepresentable+Coordinator, required below iOS 26) ·conditional(if #available(iOS 26, *)switching between the two — the real answer when your deployment target is < iOS 26).CONTENT_TRUST—bundled(your own HTML/JS viaURLSchemeHandlerorload(html:baseURL:)) ·first-party(your own web properties, fixed allowlist) ·arbitrary(user-followable external links — this is the SFSafariViewController case, not a bare WebView).JS_BRIDGE—none·read(Swift callscallJavaScript/evaluateJavaScriptto read the page) ·two-way(page posts to aWKScriptMessageHandler/ native handler — every inbound message must be validated).
When to use
Embedding web content you control inside your own UI: rendered HTML, a bundled web app, a first-party page with a native chrome around it, or a Swift↔JS bridge. If the goal is to open an arbitrary URL the user tapped (external links, "open in browser", OAuth, marketing pages), reach for SFSafariViewController — App Review treats a bare WKWebView showing third-party content as a rejection risk.