BlazorPwaKit 0.0.2

dotnet add package BlazorPwaKit --version 0.0.2
                    
NuGet\Install-Package BlazorPwaKit -Version 0.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BlazorPwaKit" Version="0.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BlazorPwaKit" Version="0.0.2" />
                    
Directory.Packages.props
<PackageReference Include="BlazorPwaKit" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BlazorPwaKit --version 0.0.2
                    
#r "nuget: BlazorPwaKit, 0.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package BlazorPwaKit@0.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BlazorPwaKit&version=0.0.2
                    
Install as a Cake Addin
#tool nuget:?package=BlazorPwaKit&version=0.0.2
                    
Install as a Cake Tool

BlazorPwaKit

A toolkit for building Progressive Web Apps (PWAs) with Blazor WebAssembly.

Still in early development.

Features

  • ServiceWorkerManager: Register, update, and unregister service workers with full lifecycle event support.
  • CachePolicyProvider: Attribute/service for per-resource caching strategies (CacheFirst, NetworkFirst, StaleWhileRevalidate, etc.).
  • OfflineFallback: Configurable component to render a “you’re offline” page or placeholder when a requested route or asset isn’t cached.
  • UpdatePrompt: UI component that detects a new service worker version and prompts the user to refresh/reload.
  • ConnectivityStatus: UI component and service for real-time online/offline state and change events.
  • Easy DI integration: One-liner setup for all services and components.

Getting Started

1. Install the NuGet Package

dotnet add package BlazorPwaKit

2. Register Services in Program.cs

using BlazorPwaKit;

builder.Services.AddBlazorPwaKit();

// Optional: customize fallback route
builder.Services.AddBlazorPwaKit(options =>
{
    options.OfflineFallbackPath = "/offline"; 
});

3. Add Usings

Add to your _Imports.razor (or at the top of your components):

@using BlazorPwaKit
@using BlazorPwaKit.Components

4. Use the Components

  • Service Worker Status:
<ServiceWorkerStatus />
  • Update Prompt:
<UpdatePrompt />

<UpdatePrompt PromptMessage="New version!" ButtonText="Update Now" PromptClass="my-update-prompt" />
  • Connectivity Status:
<ConnectivityStatus />

<ConnectivityStatus OnlineText="Connected" OfflineText="Disconnected" Class="my-conn-status" />
  • Offline Fallback:
@* Default fallback *@
<OfflineFallback />

@* Or custom content *@
<OfflineFallback>
    <div>Your custom offline message</div>
</OfflineFallback>

5. Advanced: Cache Policies

Set up cache strategies for resources in Program.cs:

var cachePolicyProvider = host.Services.GetRequiredService<ICachePolicyProvider>();
cachePolicyProvider.SetPolicyForResource(".png", new CachePolicy { Strategy = CacheStrategy.CacheFirst });
cachePolicyProvider.SetPolicyForResource("api/", new CachePolicy { Strategy = CacheStrategy.NetworkFirst });
// ...

Customization

  • All components accept parameters for text and CSS class overrides.
  • You can override styles by targeting the default class names in your own CSS.
  • For full control, use the provided services/events directly in your own components.

Example Project

See BlazorPwaKit.Example for a working demo of all features.

Requirements

  • .NET 8
  • Blazor WebAssembly

License

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.2 144 7/17/2025
0.0.1 138 7/17/2025