<!--
{
  "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/WKWebExtensionController/extensionContext(for:)-2kr4",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "WebKit"
    ],
    "preciseIdentifier" : "c:objc(cs)WKWebExtensionController(im)extensionContextForURL:"
  },
  "title" : "extensionContext(for:)"
}
-->

# extensionContext(for:)

Returns a loaded extension context matching the specified URL.

```
func extensionContext(for URL: URL) -> WKWebExtensionContext?
```

## Parameters

`URL`

The URL to lookup.

## Return Value

An extension context or `nil` if no match was found.

## Discussion

This method is useful for determining the extension context to use when about to navigate to an extension URL. For example, you could use this method to retrieve the appropriate extension context and then use its [`webViewConfiguration`](/documentation/WebKit/WKWebExtensionContext/webViewConfiguration) property to configure a web view for loading that URL.

---

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)