SwiftUI on Web (I made a transpiler.. [WIP])

Soo it turns out I got bored using TSX and HTML tags all the time for web development even though i recently got into it. I was craving something like SwiftUI for the web, a declarative syntax that does what is written instead of dwindling in using tailwind classes..

I sat down with this idea for the past month (i had my finals and was finally able to mockup this proof of concept) Now how it works is it uses SwiftSyntax and SwiftParser to navigate the Abstract Syntax Trees that Swift/SwiftUI has and writes out valid TSX backed by next.js and typescript to allow for writing Dynamic Webpages with dev candies that Next provides. I was testing out gemini-cli and opencode so I made them write all of the components in the starter template which are purely present to make the transpiler slightly dumber to debug.

This is just a personal project that tries to bridge the gap between swift on server and swiftui on web. I really loved the community initiatives and great efforts put into SwiftWebUI and TokamakShim and Ignite but they all felt a little lacking to be actually something usable (absolutely no shade on anybody else).

This is just my attempt to make something more of a usable approach. I personally really wanted to see something more native being used to write frontend for Swift on Server than Leaf as well.
swift for wasm seems promising i feel.

How it works:

  • You use the cli to create a project and can write valid SwiftUI Views.
  • Upon running the project using the CLI it copies the starter template and then generates the required .tsx files and runs the next.js application using bun.sh (just a preference)

Here is the repo: swift.js
The secondary tool i made: create-swiftjs-app (go cli for starter templates)

Feel free to help out by making a pr to extend the project or providing more constructive feedback on this idea. I’d love to hear from the community on this matter.

Are you aware of GitHub - SwiftWebUI/SwiftWebUI: A demo implementation of SwiftUI for the Web ?

Yes! I have explicitly mentioned them, I forgot to highlight them with their correct URIs.
These projects are all great points of inspiration for me, i just took a different route than them.