
A SwiftUI-style website framework, entirely in Swift
sindresorhus.com is the personal website of developer Sindre Sorhus, rebuilt entirely in Swift. The site serves plain HTML, CSS, and a little JavaScript to the browser, but every page, component, and style is written in Swift using a SwiftUI-like component model (built on the Elementary HTML library plus the author's own small framework for styles, routes, and content). The site is also a detailed writeup of how it works: a compiler that catches broken links and typos at build time, styles defined as modifiers, typed CSS variables, Markdown content with typed frontmatter, and a build that pulls live data from the App Store. The source code is open.
Components are Swift structs with a `body` property, built on the Elementary HTML library, and composed like SwiftUI views (e.g. `Badge(title: "New", kind: .new)`).
Styles attach to elements like SwiftUI modifiers and compile to hashed class names (e.g. `back-link-1x2y3z4`) derived from the file name, so styles can't leak between elements. Shared looks are enum cases that autocomplete, and typos don't compile.
Pages are static members (`.apps`, `.root`) so links autocomplete and nonexistent pages fail to compile. After the build, every link and ID in the generated HTML is verified.
CSS variables are typed (e.g. `StyleVariable<Color>`), so assigning a length doesn't compile; `RegisteredProperty` emits the `@property` rule so the browser can animate values.
Breakpoints and media queries are typed and combinable with `&&` (e.g. hover effects only applied for fine pointers with motion allowed). Colors are semantic with light/dark values and stronger contrast when the system requests it.
Each of the 60+ apps is a Markdown file with typed frontmatter validated by Swift macros (`@Frontmatter`, `@NonEmpty`, `@CalendarDay`) that reject empty values and invalid dates at compile time, with file-and-line errors and "Did you mean" suggestions.
The build pulls ratings, prices, and reviews from the App Store, and `swift run website check` catches issues the compiler can't, such as a page claiming a different macOS requirement than the App Store lists.
A blog post is about 14 KB compressed (6.6 KB HTML, 5.4 KB CSS, 1.8 KB JavaScript); pages only load their own components' CSS and scripts, with no web fonts, lazy-loaded below-fold images, background prefetch on link hover, no JavaScript framework, and no bundler.
Each component is a Swift struct conforming to `HTML` with a `body`, combining markup, styles (as modifiers), and small inline scripts for behavior in one place.
Renaming a page breaks compilation of every link to it; the build also runs tests (a few hundred) verifying things types can't catch, such as every class having a CSS rule. Warnings fail the build.
`swift run website serve` reloads the page on save during development; the final output is static HTML and CSS that any browser renders.
Sindre Sorhus's personal website, rebuilt entirely in Swift. Every page, component, and style is written in Swift; the browser receives plain HTML and CSS with a little JavaScript.
Yes. The article states that the source code is open.
The site is deliberately modeled on SwiftUI — components are structs with a `body`, styles are modifiers, and links work like SwiftUI's `Link` — so familiarity with SwiftUI makes the code familiar, though the HTML itself comes from the Elementary library.
None on the client side: there is no JavaScript framework and no bundler. The HTML comes from Elementary, with the author's own small Swift framework for styles, routes, and content on top.
A blog post is about 14 KB compressed (6.6 KB HTML, 5.4 KB CSS, 1.8 KB JavaScript), and an app page is about 29 KB before screenshots. Pages only receive the CSS and scripts of the components they show.
Each app is a Markdown file with typed frontmatter validated at compile time by Swift macros. The build also fetches ratings, prices, and reviews from the App Store, and `swift run website check` verifies facts the compiler can't.
Yes. Colors are semantic with light and dark values, text/link colors strengthen when the system requests more contrast, and hover effects are gated behind typed media queries like pointer type and reduced-motion settings.
The page does not discuss pricing; it is a personal website whose source code is open.