Progressive Web Apps (PWA)
A progressive web app (PWA) is a web application that uses modern browser features to behave like an installed app: a window of its own, a start icon, offline operation, and push notifications.
A progressive web app (PWA) is a web application that uses modern browser APIs to behave like an installed app. It runs in a window of its own, starts from the home screen, and can work offline and receive push notifications.
What makes a PWA
For Blazor PWAs, Microsoft names these capabilities: working offline and loading instantly, independent of network speed; running in an app window of its own; launching from the start menu, the dock, or the home screen; receiving push notifications from the server, even when the app is not open; updating itself in the background.
"Progressive" means: users first find the app in the browser like any other page and install it only later, if they want to. Technically, a PWA consists of three parts: a web application, a manifest file (name, icons, colors), and a service worker, a script that intercepts requests and caches files. Installation goes through the browser, for example through a button in the address bar of Edge or Chrome. On iOS, it goes through "Add to Home Screen" in Safari.
A PWA with .NET and Blazor
Blazor WebAssembly brings a project template for this:
dotnet new blazorwasm -o MyApp --pwa
The template creates a manifest, icons, and two service worker files. One of them applies during development, the other after publishing. Offline support is therefore only active in the published app. The published variant takes answers from the cache first. The app loads new versions in the background, but they only become active once the user has left the app in all tabs.
When offline operation pays off
Microsoft explicitly advises that not every app should aim for offline use, because it brings considerable complexity. It makes sense above all when the main data lives in the browser, when the app preloads a lot of data for browsing offline (with reconciliation on changes), or when it has to start instantly even on a bad network. With sign-in it is tricky: without a network, there is no new token.
How it differs
- PWA and native app: A PWA runs in the browser's sandbox. What it may do is set by the browser APIs. When a native app makes more sense is covered on the blog.
- PWA and web app: Every PWA is a web app, but not every web app can be installed or work offline.
- PWA and a responsive page: A page that adapts to the screen is not yet a PWA.
In the course
The academy does not teach PWAs as a topic of its own. You learn the foundation in K2, module 2.5: interactive islands with WebAssembly in Interactive islands with WebAssembly, the Kladde's user interface in The Blazor Web App.
Further reading on the blog
- Push notifications: when they make sense
- Native apps: when they make more sense
- Responsive design explained simply
Sources
- Microsoft Learn, ASP.NET Core Blazor Progressive Web Application (PWA): https://learn.microsoft.com/aspnet/core/blazor/progressive-web-app/?view=aspnetcore-10.0
- Microsoft Learn, ASP.NET Core Blazor hosting models: https://learn.microsoft.com/aspnet/core/blazor/hosting-models?view=aspnetcore-10.0