Your logic, in a context.
Keep business operations together. Typed models and repository-backed contexts give your HTML pages and JSON API the same source of truth.
A good home for your next Swift app.
Phoenix-inspired structure. Swift from route to response. Roost brings the pieces together, so you can get on with your idea.
Built on Nexus, Spectro, and ESW.
import Roost
@main
struct Hello: RoostApp {
@RouteBuilder
var routes: [Route] {
GET("/", PageController.self, .home)
}
}
struct PageController: Controller {
enum Action: String, ControllerAction { case home }
static func action(_ action: Action) -> Plug {
switch action { case .home: home }
}
static func home(_ conn: Connection) async throws -> Connection {
conn.text("Hello, Roost.")
}
}
One route, one action. A place to begin.
Good company.
One Swift stack.
A LITTLE STRUCTURE GOES A LONG WAY
Keep business operations together. Typed models and repository-backed contexts give your HTML pages and JSON API the same source of truth.
Sessions, forms, CSRF protection, and flash messages. Validation that keeps what someone typed. The details a web app needs, connected.
Test the application pipeline in process. Keep cookies between requests and inject a transaction repository to isolate database tests.
Familiar if you know Phoenix.
Native to the way you write
Swift.
FROM THE FIRST ROUTE TO THE REAL THING
Generate the connections. Write the parts that make it yours.
An app, authentication, then an owner-scoped resource. The generators create models, contexts, migrations, controllers, templates, and input tests together.
The reading-list example adds its own design, filters, and a “mark as read” action.
Meet the example# Give your idea a home
roost new RoostExample
cd RoostExample
# Add sign up, sign in, and sign out
roost gen auth
# One context. HTML and JSON.
roost gen resource Bookmark \
title:string url:string \
note:text read:bool \
--both --scope user_id
Development API preview. The renamed Roost release and ESW template updates are still being prepared. Current status
The context takes a repository and an authenticated scope. Reads stay inside the current user’s collection.
BookmarksContext.swift · excerptfunc listBookmarks(scopeId: UUID) async throws -> [Bookmark] {
try await repo.query(Bookmark.self)
.where({ $0.userId == scopeId })
.orderBy(\.createdAt, .asc)
.all()
}
Update the reading state, leave a one-time flash message, and send the reader back to their queue.
BookmarkController.swift · excerptlet params = try conn.permit(ReadParams.self)
try await BookmarksContext(repo: conn.repo())
.setRead(id: id, read: params.read, scopeId: readerID(conn))
return conn
.putFlash(.info, "Moved to finished")
.redirect(to: "/bookmarks")
Exercise your app without opening a port. Swift Testing and RoostTest keep a simple route test simple.
HelloTests.swiftimport Testing
import RoostTest
@Test func saysHello() async throws {
let app = try await TestApp(Hello.self)
let response = try await app.get("/")
#expect(response.status == .ok)
#expect(response.text == "Hello, Roost.")
}
A SMALL APP WITH A LOT CONNECTED
A quiet place for things you want to come back to.
COLLECT YOUR CURIOSITY
Three good things for later.
The Swift example connects authentication, owner-scoped bookmarks, ESW pages, a JSON API, and Spectro migrations.
This browser-only preview lets you save and finish links. It resets on reload. The Swift app itself runs on PostgreSQL.
ROOST PLAYGROUND / BROWSER EDITION
A counter, a greeting, a change of state. Edit a guided example and see the result, right in your browser.
Runs locally in your browser. No Swift compiler.
BUILT IN THE OPEN
Roost is in active development. Here’s where things stand.
The goal is a connected development experience for server-side Swift: from the first route to an app you can understand and keep growing.
Follow development on GitHubRoost 2.5.0 supports generated authentication, scoped CRUD, HTML and JSON controllers, permitted parameters, form validation, per-action logs and traces, Spectro migrations, live pages, reusable form fields, key-value stores, channels, jobs kept in PostgreSQL, HTTPS, and in-process tests. The reading-list workflow has been exercised against real PostgreSQL.
Start with Roost 2.5.0 and follow the README quickstart to generate your first app. The CLI connects routes, templates, data, and tests, with published dependencies resolved by SwiftPM.
Development prerequisites are Swift 6.3+, macOS 15+ or Linux, and PostgreSQL for database-backed apps. Roost uses Nexus 2.x (from 2.1.0), Spectro 2.x (from 2.3.1), and ESW 1.7.0; no companion checkouts are required.
View releases
Phoenix inspires the application structure, contexts,
controllers, generators, and browser conventions. Routes name
controller actions the compiler checks, and
resources, controller plugs, and permitted
parameters work as they do in Phoenix. Roost uses Swift’s type
system and package tooling. Live pages use ESW Live for server-rendered
HTML and interactive updates, with session ownership and CSRF protection.
Roost does not claim feature parity with Phoenix.
SMTP delivery still has unfinished integration. The example uses in-memory sessions; persistent deployments can use KeyValueSessionStore with Valkey. Live page state remains process-local.
Give your next idea
a good home.