Run Your SwiftUI App on a Swift Server. Serve Many Clients with Your SwiftUI Web App.
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
- provide the SwiftWeb HTML template (
HTMLTemplate.withContent("")) under a URL of your desire,
- implement a WebSocket endpoint under
/websocketon your server and connect it to a
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!")
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.