Installation
One package, one optional service registration.
Install the package#
dotnet add package Deja
Deja multi-targets net8.0, net9.0 and net10.0 and works
on both Blazor WebAssembly and Blazor Server. It has no third-party dependencies.
Register the cache (recommended)#
AddDeja() registers the shared query cache. It's opt-in: without it, everything
still works, but keyed queries don't share results across components.
using Deja;
builder.Services.AddDeja(options =>
{
options.DefaultStaleTime = TimeSpan.FromSeconds(10);
options.DefaultCacheTime = TimeSpan.FromMinutes(5);
});The options shown are this site's own configuration. Every property has a sensible default — see DejaOptions for the full list.
AddDeja() registers DejaClient as Scoped deliberately:
one cache per browser tab on WebAssembly, one per user circuit on Server. Re-registering it
as a singleton on Blazor Server would share one user's cached API responses with every
other connected user — a data leak, not a performance win.
Add the using#
@using DejaInherit the component base#
Components that own queries or mutations inherit DejaComponentBase, which attaches
to declared state and re-renders the component when it changes:
@inherits DejaComponentBaseContinue with the quick start.