Skip to content

Getting Started

André Borchert edited this page Aug 11, 2026 · 26 revisions

Getting Started

Requirements

The active package requires:

  • macOS 26 or later
  • Swift 6.3
  • Swift language mode 6

These requirements are declared by both Package.swift and Swift/Package.swift.

Add the package

Use the repository-root package for application and library integration:

.package(
    url: "https://github.com/Pummelchen/WebTransport.git",
    exact: "1.1.0"
)

The primary library product is WebTransport. Lower-level products are also available for applications that need direct access to the network runtime, HTTP/3, QUIC, TLS, Apple crypto, or loopback UDP modules.

Minimal client

import Foundation
import WebTransport

let client = WebTransportClient(configuration: WebTransportClientConfiguration(
    authority: "example.com",
    path: "/wt",
    origin: "https://example.com",
    availableProtocols: ["demo.v1"]
))

let endpoint = WebTransportEndpoint(host: "example.com", port: 443)
let session = try await client.connect(to: endpoint)
let stream = try await session.openBidirectionalStream()
try await stream.send(Data("hello".utf8), endOfStream: true)
let response = try await stream.receive()

The runtime uses platform trust by default.

Run the command-line tools

Show the available commands and scenarios:

swift run WebTransportClient --help
swift run WebTransportServer --list

Start a local IPv4 server:

swift run WebTransportServer --listen 127.0.0.1:4433 --transport packet

Connect from another terminal:

swift run WebTransportClient \
  --connect 127.0.0.1:4433 \
  --transport packet \
  --trust local-self-signed

For IPv6 loopback, use [::1]:4433 for both endpoints.

Real --listen and --connect sessions require packet transport. Frame transport is available only to lower-level conformance scenarios. The local-self-signed trust mode must be selected explicitly and is restricted to localhost, 127.0.0.1, and ::1.

Next steps

Clone this wiki locally