Run in a Browser
Fyne applications can also be run over the web using a standard web browser! Due to the wide variety of standards and strenghts of different engines this is a little more complex.
To prepare your app to be used over the web we use the “fyne” cli app again, which has a “serve” command for quick testing
go install fyne.io/fyne/v2/cmd/fyne@latest
You will see, after a few moments, that a web server has been started on port :8080. Just open your web browser to https://localhost:8080 and you can use your app!
The tools used in this process are very sensitive to Go versions being used, so it is possible there will be an error relating to a mis-matched version. If you are using Go more recent than 1.18 you should ensure you have a copy of the 1.18 release and reference it in your environment, such as (for a homebrew based install):
You can find out more about this on the GopherJS documentation.
Packaging for web distribution
fyne serve command is great for local testing, but just like other platforms you’ll want
to be able to distribute your app as well. To prepare the files for upload just use the
fyne package command like with regular Packaging.
fyne package -os web
fyne package -os wasm
fyne package -os js
You can see a Fyne app in action to test on any of your devices by visiting demo.fyne.io.
As of release v2.4.0 the web driver is not 100% complete, so your app may not be able to use the following features:
- Multiple windows (but dialogs all function inside the current window)
- Storage of Documents and Preferences
These issues are being worked on and will be resolved in a future release.