Swiftpack.co -  Alja7dali/swift-web-page-vapor as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
💧 Vapor plugin for type-safe HTML/CSS views.
.package(url: "https://github.com/Alja7dali/swift-web-page-vapor.git", from: "0.0.1")

💧 swift-web-page-vapor

Swift Version: 5.1 Swift Package Manager Swift Package Manager

Vapor plugin for type-safe HTML/CSS views using Swep.


The most popular choice for rendering HTML/CSS in a Vapor web app is to use the Leaf templating language, but it exposes your application to runtime errors and invalid HTML/CSS. Our plugin prevents these runtime issues at compile-time by embedding HTML/CSS directly into Swift’s powerful type system. It uses the Swep DSL for constructing HTML/CSS documents using plain Swift data structures.


To use the plugin all you have to do is return a Document or Stylesheet value from your router callback:

import Swep
import Vapor
import SwepVaporSupport

var env = try Environment.detect()
let app = Application(env)
defer { app.shutdown() }

app.get { _ in
  document {
    head {
      style {
        selector("*") {
    body {
      h1("Hello, type-safe HTML/CSS on Vapor!")

app.get("style.min.css") {
  stylesheet {
    selector("body") {
    selector("h1") {

try app.run()

Take it for a spin

We've included a sample Vapor application in this repo to show off its usage. To run the app immediately, simply do:

  • swift run SwepVaporSupportExample
  • Open your browser to http://localhost:8080

The HTML/CSS for that page is constructed and rendered with Swep!!


Swift Package Manager (SPM)

If you want to use swift-web-page-vapor in a project that uses SPM, it's as simple as adding a dependencies clause to your Package.swift:

dependencies: [
  .package(url: "https://github.com/alja7dali/swift-web-page-vapor.git", from: "0.0.1")

From there you can add SwepVaporSupport as target dependencies.

let SwepVaporSupport: Target.Dependency = .product(name: "SwepVaporSupport", package: "swift-web-page-vapor")
targets: [
  .target(name: "yourProject", dependencies: [SwepVaporSupport]),


All modules are released under the MIT license. See LICENSE for details.


Stars: 1
Last commit: 1 week ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Submit a free job ad (while I'm testing this). The analytics numbers for this website are here.

Release Notes

1 week ago

SwepVaporSupport initial release

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics