<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: -",
    "macOS: 26.0.0 -",
    "visionOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "WebKit",
  "identifier" : "/documentation/WebKit/URLSchemeHandler",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "WebKit"
    ],
    "preciseIdentifier" : "s:6WebKit16URLSchemeHandlerP"
  },
  "title" : "URLSchemeHandler"
}
-->

# URLSchemeHandler

A protocol for loading resources with URL schemes that WebKit doesn’t handle.

```
protocol URLSchemeHandler
```

## Overview

Adopt the `URLSchemeHandler` protocol in types that handle custom URL schemes for your web content.
Custom schemes let you integrate custom resource types into your web content, and you may define
custom schemes for resources that your app requires. For example, you might use a custom scheme to
integrate content that is available only on the user’s device, such as the user’s photos. These types
can then be registered to a particular WebPage by using the [`urlSchemeHandlers`](/documentation/WebKit/WebPage/Configuration/urlSchemeHandlers)
property of [`WebPage.Configuration`](/documentation/WebKit/WebPage/Configuration).

When a web page encounters a resource that uses a custom scheme, it passes the `URLRequest` to the
scheme handler, and expects a stream of responses and data to load the result.

If WebKit determines that it no longer needs a resource that your handler is loading, it will cancel
the Task responsible for the async sequence. Typically, this may happen when the user navigates to another
page, but may happen for other reasons.

## Topics

### Associated Types

[`associatedtype TaskSequence : AsyncSequence`](/documentation/WebKit/URLSchemeHandler/TaskSequence)

The type of sequence produced by the handler.

### Instance Methods

[`func reply(for: URLRequest) -> Self.TaskSequence`](/documentation/WebKit/URLSchemeHandler/reply(for:))

Produces a sequence of intermixed responses and data to load a resource for a given request.

---

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)