Stale-While-Revalidate for Blazor

SWR .NET

Cache first. Revalidate in the background.
Keep every component in sync.

Get Started $ dotnet add package Swr.Net
Home.razor
@inject ISwr Swr
@implements IDisposable

@if (result?.Data is not null)
{
    <h2>@result.Data.Name</h2>
    <span>@result.Data.Email</span>
}

@code {
    private SwrResult<User>? result;

    protected override async Task OnInitializedAsync()
    {
        result = await Swr.GetAsync<User>("/api/me");
    }

    public void Dispose() => result?.Dispose();
}
01

Stale

Return cached data instantly. Your UI is never blocked waiting for the network.

02

Revalidate

Fetch fresh data in the background. No loading spinners, no layout shifts.

03

Update

Swap in the latest data. Every subscriber re-renders automatically.

Global Cache

Share data across components. One fetch populates the cache, every subscriber stays in sync without prop drilling.

Auto Revalidation

Data refreshes on window focus, network reconnect, and configurable intervals. Always fresh, zero effort.

Blazor Native

Built for Blazor Server and WebAssembly from the ground up. Integrates with the component lifecycle naturally.

Type Safe

Full generic type support with compile-time checking. Fetcher return types flow through the entire pipeline.