Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?


Failed to load latest commit information.
Latest commit message
Commit time

SwiftWeb logo


Run Your SwiftUI App on a Swift Server. Serve Many Clients with Your SwiftUI Web App.

SwiftWeb logo

With SwiftWeb, you can easily provide a web interface to your existing SwiftUI app. SwiftWeb renders SwiftUI code to HTML and CSS and keeps a WebSocket connection to connected Browsers. User input events are sent to your Swift server which runs your application logic. Screen updates are sent back to connected clients.


The SwiftWeb framework is intentionally kept independant of any HTTP / WebSocket server implementation. In order to provide a user interface over the web, you need to

  1. provide the SwiftWeb HTML template (HTMLTemplate.withContent("")) under a URL of your desire,
  2. provide the JavaScript client script (JavaScriptClient.script) under /script.js and
  3. implement a WebSocket endpoint under /websocket on your server and connect it to a SwiftWebServer instance.

Have a look at the example implementation of an XCode project running an HTTP and WebSocket server together with SwiftWeb.


Simply instantiate a server instance with a view instance:

let swiftWebServer = SwiftWebServer(contentView: Text("Hello World!")

Hello World Screenshot

The JavaScript client will connect to the server instance using a WebSocket connection and load the current state of the interface.

Check out the example project implementing various view components with SwiftWeb.


Contributions to this projects are welcome. Please make sure to read the contribution guidelines first.


This project is licensed under the MIT License. See License for more information.