<!--
{
  "availability" : [
    "iOS: 18.4.0 -",
    "iPadOS: 18.4.0 -",
    "macCatalyst: 18.4.0 -",
    "macOS: 15.4.0 -",
    "visionOS: 2.4.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "WebKit",
  "identifier" : "/documentation/WebKit/WKWebExtensionTab/webView(for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "WebKit"
    ],
    "preciseIdentifier" : "c:objc(pl)WKWebExtensionTab(im)webViewForWebExtensionContext:"
  },
  "title" : "webView(for:)"
}
-->

# webView(for:)

Called when the web view for the tab is needed.

```
optional func webView(for context: WKWebExtensionContext) -> WKWebView?
```

## Parameters

`context`

The context in which the web extension is running.

## Discussion

The web view’s [`WKWebViewConfiguration`](/documentation/WebKit/WKWebViewConfiguration) must have its [`webExtensionController`](/documentation/WebKit/WKWebViewConfiguration/webExtensionController) property set to match the controller of the given context; otherwise `nil` will be used. Defaults to `nil` if not implemented. If `nil`, some critical features will not be available for this tab, such as content injection or modification.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)