bit Bswup

Preparing the app for offline use, please wait...

0%

Blazor WebAssembly, without the blank first paint

Ship Blazor PWAs that install, update & work offline.

Bswup replaces the default Blazor service worker experience with a real install progress UI, controlled background updates, resilient downloads, and a tiny JavaScript API - all from a single script tag.

dotnet add package Bit.Bswup
1 script tag is the entire wiring
11 lifecycle events your handler can act on
29 documented settings, each with its default
0 third-party dependencies
The problem

A blank page on the first visit, a stale build for days after

A Blazor WebAssembly app has to download a runtime and your assemblies before it can render anything. The standard template hides that behind a blank page, and hides updates behind nothing at all: a new version only takes effect once every tab of your app has been closed.

SituationStandard Blazor templateWith Bswup
First visit Blank page while the runtime downloads. No indication anything is happening. A branded splash with an honest progress bar, counting the very bytes the app is waiting on.
Updates Staged silently, applied only after every tab closes. Users can run a stale build indefinitely. Downloaded in the background, then announced. The user accepts, and every open tab moves together.
Flaky network One failed asset fails the whole install. No retries, no reporting. Retries with backoff, choice of lax or strict tolerance, and structured error payloads.
Install goes wrong Nothing is watching. A worker killed mid-install leaves the page hanging. A stall watchdog boots the app from the network instead. A first visit never dead-ends.
Control Edit the generated worker and hope. Script attributes, worker settings, lifecycle events, and a JavaScript API.
Where to start

Three steps from installed to shipped

A route through the documentation rather than an index of it.

Capabilities

What you get

Every card links to the page that documents it in full.

In one paragraph

What is Bswup?

bit Bswup (Blazor service-worker update progress) is a NuGet package for Blazor WebAssembly apps that takes over the service worker lifecycle: it downloads and caches your app's assets with visible progress, verifies their integrity, serves them offline, and manages version updates without ever leaving your users staring at a blank page - or running a stale build for days.

This documentation site is itself a prerendered Blazor WebAssembly app powered by Bswup - open the browser dev tools, go offline, and reload. Then head over to the Live Playground to watch the service worker events in real time.

Architecture

How it fits together

Five pieces, each with one job.

PieceWhat it does
bit-bswup.js Page-side script: registers the service worker, coordinates the install/update handshake, starts Blazor at the right moment, polls for updates, and raises lifecycle events.
bit-bswup.sw.js The service worker engine: precaches assets (with retries and integrity checks), serves fetches from cache, handles SPA navigation fallback, and stages new versions. Imported from your service-worker.js.
bit-bswup.progress.js + BswupProgress The optional built-in progress UI: splash screen, progress bar, reload button, and failure panel - CSP-friendly and screen-reader aware.
BitBswup A small JavaScript API to check for updates, activate staged versions, request persistent storage, and force-reset a broken client.
bit-bswup.sw-cleanup.js A self-destructing worker to back out of Bswup or recover clients stuck on a broken worker or cache.

How It Works walks through what each of them does at runtime - the boot handshake, the two lifecycles, and the request pipeline.

Runnable code

Sample projects

Besides this documentation site, the repository ships two runnable samples.

  • Samples/BasicSample (Bit.Bswup.BasicSample) - a minimal standalone Blazor WebAssembly app with a hand-written handler, deliberately including a failing external asset to exercise the error flow.
  • Samples/FullSample (Bit.Bswup.FullSample.*) - a Blazor Web App (server + client) using the BswupProgress component with a custom progress bar.