PWA like installation #3810
PeterMarkuson
started this conversation in
Show and tell
Replies: 1 comment 3 replies
-
@PeterMarkuson Thanks for sharing! with the server worker to cache all static files, will your web app reload after opening from iPhone Home Screen |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi guys,
I have been working on PWA support for NiceGUI and found #246 which is already closed. So, let me share my achievements in addition to that old thread also here.
Disclaimer: I am not a professional programmer and have only minor knowledge in JavaScript. If anybody has come up with a better solution or can improve my approach, I would be happy to see that :)
You can achieve the "pwa" look with that neat install button by providing a manifest file and a service_worker.js. If a user visits your page, he will see a notification to install the app. And of cause you can use the APIs from the browser (like notifications) to make your app look even more native.
However, this will not lead to a pure offline experience, because the backend needs to be there. But, it leads to a nice setup for new users and a better experience with a startup logo and full-screen instead of browser tab.
You need these four ingredients:
This is manifest.json. Please replace the values in capital to your liking
This is an optimized service-worker who caches static files (e.g. media), but does nothing on web-socket-connections:
You need to bind these to files with the
app.add_static_file
command and then the following in your page where it should appear:BR/Peter
Beta Was this translation helpful? Give feedback.
All reactions