Swift-WebServicesErgonomic and very fast server-side Swift.
@Handler(method: .GET)
struct GetGreeting {

    @Query("name")
    var name: String

    func handle() async throws -> String {
        "Hello, \(name)!"
    }
}
Coming soon
Strong Foundation
Compile-Time GuaranteesNotice incorrectly wired dependencies during builds.
let app = WebServiceApp { environment in
    let apiKey = try environment.get("API_KEY")

    Homepage(apiKey: apiKey) {

        HTTP(host: "127.0.0.1", port: 8080) {
            Logging.resolve
        } plugins: {
            OpenAPI() {
                Logging.resolve
            }
        }

        Logging {
            StandardOutputLogging(level: .info)
            StandardErrorLogging(level: .error)
        }
    }
}
try await app.run()
Elegant Endpoint APIDefine request path, request parameters and type-safe response schemas with zero runtime overhead.
@Handler(method: .POST, path: "greet")
struct GreetUser {

    @Query("locale")
    var locale: BCP47Locale = BCP47Locale(languageCode: .english)

    @Body
    var user: User

    @Responding(status: .ok)
    var response

    func handle() async throws -> String {
        switch locale.languageCode {
        case .german:
            return "Hallo, \(user.name.capitalized)!"
        case .french:
            return "Bonjour, \(user.name.capitalized)!"
        default:
            return "Hello, \(user.name.capitalized)!"
        }
    }
}
Built-in Streaming
WebSocketA WebSocket endpoint is just a handler that returns a WebSocketResponse, giving you a duplex stream of inbound and outbound messages to read from and write to with ordinary async iteration.
@Handler(method: .GET, path: "echo")
struct GetEcho {

    func handle() async throws -> WebSocketResponse {
        WebSocketResponse { inbound, outbound in
            for await message in inbound {
                outbound.yield(message)
            }
        }
    }
}
Server-Sent EventsServer-sent events push a one-way stream of updates to the browser over a single connection, which makes them a great fit for LLM-based, streaming-token applications such as relaying a model's output to the page token by token.
@Handler(method: .GET, path: "prices")
struct GetPrices {

    func handle() async throws -> SSEResponse {
        SSEResponse { continuation in
            for await price in priceFeed {
                continuation.yield(data: price, event: "price")
            }
            continuation.finish()
        }
    }
}
Web Page Rendering
High WHATWG CoverageNearly the entire HTML standard is available as typed elements, discoverable through code-completion and checked by the compiler.
Article {
    HeaderSection {
        Heading1 { Text(post.title) }
        Time(post.publishedAt)
    }
    Paragraph { Text(post.lead) }
    Figure {
        Image().src(post.imageURL)
        FigureCaption { Text(post.caption) }
    }
}
Built-in Design SystemA pre-built, customizable design system gives you semantic layout, typography and color out of the box, and ships as less than 15 KB of CSS.
VStack {
    Text(string: title)
        .fontSize(.largeTitle)
        .fontWeight(.bold)

    for product in products {
        HStack {
            Text(string: product.name)
            Spacer()
            Text(string: product.price)
                .fontWeight(.semiBold)
        }
        .padding(.vertical, ._2)
    }
}
.gap(._4)
.padding(._5)
First-class HTMX 4 SupportCoverage for most htmx features working with code-completion and checked by the compiler.
Button {
    Text(string: "Load more")
}
.hxGet(baseURI + GetArticles.uri(page: nextPage))
.hxTarget("#feed")
.hxSwap(.append)
.hxTrigger("click")
Overview
WHATWG coverageNearly the entire HTML standard available as typed elements with code-completion
HTMX coverageFirst-class support for most htmx features working with code-completion
LayoutVStack, HStack, ZStack, Grid, WrappingHStack, ScrollView, Spacer
TypographySemantic font sizes, weights, families and text styles
ColorSemantic colors with automatic light & dark mode
Spacing & sizingA unified scale with %, viewport and container units
ResponsivePer-breakpoint modifiers for mobile, tablet and desktop
DecorationBorders, corner radius, overflow and object-fit
Resource BundlingFirst-class static asset management with content-addressed URLs and integrity checksums
Reverse linksType-safe link generation from handler definitions
Competitive Performance
Stays fast as endpoints grow
swift-webservices
Vapor
Hummingbird
0
35
70
105
140
baseline
hello
guarded
greet
localized
cookie
endpoint complexity →Requests per second (thousands), by endpoint of growing complexity · 10s · 10 threads · 256 connections.
Accelerated Hot PathsThe framework accelerates common hot paths — parsing RFC 9110 dates, BCP 47 locales, and Cookie and Set-Cookie headers — by reaching for CPU intrinsics wherever they make a measurable difference.
RFC 9110 date parsing — throughput (ops/s)
WebServiceHTTP
1,677,728 / s
Foundation
29,067 / s
58x faster than Foundation.
BCP 47 locale parsing — throughput (ops/s)
WebUICore
1,340,929 / s
Foundation
229,338 / s
≈5.8× faster than Foundation.
Rendering Web Pages In Pure SwiftPages are rendered from scratch on every request, yet WebUICore still outpaces the established templating engines.
Rendering a dynamic table
WebUICore
54,618 / s
Elementary
30,789 / s
Vapor HTMLKit (stateful cache)
30,589 / s
LeafKit (stateful cache)
2,345 / s
Rendering a static page
LeafKit (stateful cache)
142,678 / s
WebUICore
109,534 / s
Vapor HTMLKit (stateful cache)
98,023 / s
Elementary
77,066 / s
Ready to build?Explore the documentation and the example projects on GitHub to see how the pieces fit together, then start your own service.
Coming soon
Copyright © 2025 Anton Lorani. Alle Rechte vorbehalten.Schweiz