One Logo Pool Ball
_WebKit_SwiftUI · IOS API REFERENCE

WebView

struct · iOS 26.0+ · SDK 27.1

@MainActor @preconcurrency struct WebView

A view that displays some web content. Connect a ``WebView`` with a ``WebPage`` to fully control the browsing experience, including essential functionality such as loading a URL. Any updates to the webpage propagate the information to the view.

Members (2)

init · iOS 26.0+

init

TypeScript
static initUrl(url?: (string) | null): Promise<WebView>
Swift declaration
@MainActor @preconcurrency init(url: URL?)

Create a new WebView with the specified URL. For example, you can create a WebView that displays one of two URLs depending on the state of a toggle: ```swift struct URLView: View { @State private var url: URL? = nil @State private var toggle = false var body: some View { VStack { Button("Toggle") { toggle.toggle() } WebView(url: url) } .onChange(of: toggle, initial: true) { url = toggle ? URL(string: "https://www.webkit.org") : URL(string: "https://www.apple.com") } } } ``` - Parameter url: The URL to display in the view. If this value is non-nil or changes to become a non-nil value, the new URL is loaded into the view.

init · iOS 26.0+

init

TypeScript
static init(page: _WebKit_WebPage): Promise<WebView>
Swift declaration
@MainActor @preconcurrency init(_ page: WebPage)

Create a new WebView. - Parameter page: The ``WebPage`` that should be associated with this ``WebView``. It is a programming error to create multiple ``WebView``s with the same ``WebPage``.

Skipped declarations

1 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

WebView.body

This protocol needs associated types that cannot yet cross the bridge.

All _WebKit_SwiftUI types →