// SwiftData, for the server
Share @Model classes between your iOS app and your Vapor backend. The SwiftData API you already know — running on PostgreSQL, MySQL, and SQLite.
// proof of concept: this website is a Vapor app persisting with SwiftDataServer
// Works on iOS, macOS, and Linux
@Model
final class User {
var name: String
@Attribute(.unique)
var email: String
@Relationship(deleteRule: .cascade)
var posts: [Post] = []
init(name: String, email: String) {
self.name = name
self.email = email
}
}
01 — One mental model
Most full-stack Swift teams write their models twice: once in SwiftData for the app, once in an ORM dialect for the server — then keep the two in sync by hand.
SwiftDataServer removes the second world. #Predicate, FetchDescriptor, and ModelContext behave the way they do on iOS — queries compile to SQL instead of touching a local store.
// The same query you'd write in your app
let adults = try await context.fetchAsync(
FetchDescriptor<User>(
predicate: #Predicate { $0.age >= 18 }
)
.sorted(by: SortDescriptor(propertyName: "name"))
)
// SELECT * FROM users WHERE age >= 18 ORDER BY name ASC
02 — What's in the box
The same @Model, #Predicate, FetchDescriptor, and ModelContext you know from SwiftData — share model files verbatim.
PostgreSQL and MySQL for production, SQLite for development and tests, and a REST backend that persists through any HTTP API instead of a database.
Request-scoped contexts, response helpers, pagination, and automatic migrations on boot. Swift 6 strict concurrency throughout.
One-to-many and many-to-many with automatic join tables, lazy loading, and cascade / nullify / deny delete rules that behave like the originals.
Schema changes are detected and applied on boot. No migration files to write, number, or argue about in review.
Predicates are checked by the compiler and translated to parameterized SQL — composable, injection-safe, and identical to Apple's syntax.
03 — Ship it
A perpetual license for your whole organization. Unlimited projects, all future updates.