<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: -",
    "macOS: 11.0.0 -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "WebKit",
  "identifier" : "/documentation/WebKit/WKWebView/createWebArchiveData(completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "WebKit"
    ],
    "preciseIdentifier" : "s:So9WKWebViewC6WebKitE06createC11ArchiveData17completionHandleryys6ResultOy10Foundation0G0Vs5Error_pGc_tF"
  },
  "title" : "createWebArchiveData(completionHandler:)"
}
-->

# createWebArchiveData(completionHandler:)

Creates a web archive of the web view’s current contents asynchronously.

```
@MainActor @preconcurrency func createWebArchiveData(completionHandler: @escaping @MainActor @Sendable (Result<Data, any Error>) -> Void)
```

## Parameters

`completionHandler`

The completion handler block to call when the web archive data is ready. This block has no return value and takes the following parameters:

- data: A data object that contains the web archive.
- error: An error object if an error occurs, or `nil` on success.

## Discussion

---

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)