Skip to content

GeminiKit

Latest

Choose a tag to compare

@boek boek released this 25 Apr 23:40

GeminiKit 1.0

GeminiKit is a Swift library for the Gemini protocol, a minimal, TLS-only alternative to the web. Version 1.0 ships a server framework, a client, and a GemText parser, all written for Swift 6 strict concurrency.

Server

The server API is modeled after SwiftUI's view builder pattern. You conform a struct to Server, declare your routes in body, and GeminiKit handles the NIO pipeline, TLS termination, and request dispatch:

@main
struct MyServer: Server {
    let config = Config(
        certificatePath: URL(filePath: "/path/to/cert.pem"),
        privateKeyPath: URL(filePath: "/path/to/key.pem")
    )

    var body: some Route {
        Path("/") { Success("Hello, Gemini!") }

        Match("/users/:id") { params in
            Success("Hello, \(params.id ?? "stranger")!")
        }

        Path("/ask") {
            Input("What is your name?") { name in
                Success("Hello, \(name)!")
            }
        }
    }
}

The full Gemini status space is covered: redirects, rate limiting, client certificates, permanent failures.

Client

GeminiClient fetches URLs, follows redirects, and handles TLS using Trust-On-First-Use by default:

let client = GeminiClient()
let response = try await client.fetch(URL(string: "gemini://geminiprotocol.net/")!)

GemText

GemTextDocument parses GemText into a typed, exhaustive enum — headings, links, lists, blockquotes, preformatted blocks — ready to render or transform.

Requirements: macOS 26, Swift 6.3