<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: -",
    "macOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "WebKit",
  "identifier" : "/documentation/WebKit/WKUserContentController/addBuffer(_:name:to:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "WebKit"
    ],
    "preciseIdentifier" : "s:So23WKUserContentControllerC6WebKitE9addBuffer_4name2toys7RawSpanV_SSSo14WKContentWorldCtF"
  },
  "title" : "addBuffer(_:name:to:)"
}
-->

# addBuffer(_:name:to:)

Adds a data buffer that will be available to JavaScript through the `window.webkit.buffers` object.

```
@MainActor @preconcurrency func addBuffer(_ buffer: RawSpan, name: String, to contentWorld: WKContentWorld)
```

## Parameters

`buffer`

The buffer to add.

`name`

The name of the buffer to be referenced from JavaScript.
e.g. with a `name` parameter of `"mybuffer"`, JavaScript can reference the buffer via `window.webkit.buffers.mybuffer`.

`contentWorld`

The `WKContentWorld` to add the buffer to.
The buffer will only be visible to JavaScript executing in that content world.

---

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)