Soenneker.Blazor.Dayjs
11.0.332
Prefix Reserved
dotnet add package Soenneker.Blazor.Dayjs --version 11.0.332
NuGet\Install-Package Soenneker.Blazor.Dayjs -Version 11.0.332
<PackageReference Include="Soenneker.Blazor.Dayjs" Version="11.0.332" />
<PackageVersion Include="Soenneker.Blazor.Dayjs" Version="11.0.332" />
<PackageReference Include="Soenneker.Blazor.Dayjs" />
paket add Soenneker.Blazor.Dayjs --version 11.0.332
#r "nuget: Soenneker.Blazor.Dayjs, 11.0.332"
#:package Soenneker.Blazor.Dayjs@11.0.332
#addin nuget:?package=Soenneker.Blazor.Dayjs&version=11.0.332
#tool nuget:?package=Soenneker.Blazor.Dayjs&version=11.0.332
Soenneker.Blazor.Dayjs
A Blazor wrapper around Day.js for relative timestamps and humanized durations, with Razor components for live clocks and countdowns.
Installation
dotnet add package Soenneker.Blazor.Dayjs
Setup
using Soenneker.Blazor.Dayjs.Registrars;
builder.Services.AddDayJsInteropAsScoped();
Initialize the plugins your application uses before rendering a relative-time component or calling the interop service. A layout or other parent component is a convenient place:
@using Soenneker.Blazor.Dayjs.Abstract
@using Soenneker.Blazor.Dayjs.Configuration
@inject IDayJsInterop DayJs
@code {
protected override async Task OnInitializedAsync()
{
await DayJs.Initialize(new DayJsOptions
{
LoadRelativeTime = true,
LoadDuration = true
});
}
}
UseCdn defaults to true. Set it to false to load the Day.js files packaged with this library instead of jsDelivr. Initialization is shared by the scoped service, so choose the complete plugin set on the first call.
Components
Add the component namespace to _Imports.razor:
@using Soenneker.Blazor.Dayjs
Relative time
<DayJsRelative Value="article.PublishedAt"
UpdateInterval="30s" />
This renders values such as 5 minutes ago. It requires LoadRelativeTime. Set WithoutSuffix="true" for text such as 5 minutes, or AutomaticUpdate="false" for a single calculation.
Live clock
<DayJsNow Format="HH:mm:ss" UpdateInterval="1s" />
Format is a .NET date/time format string. Timezone is resolved by .NET's TimeZoneInfo; if omitted, the process/browser local time is used.
Countdown
<DayJsUntil Value="eventStartsAt"
Format="d.hh:mm:ss"
UpdateInterval="1s" />
Format is a custom .NET TimeSpan format; colons are escaped for you. Expired countdowns render zero by default. Set ClampToZero="false" to keep displaying a negative duration.
Intervals accept a TimeSpan value or a positive number followed by ms, s, m, h, or d. Invalid and non-positive component intervals fall back to that component's default.
Interop API
Inject IDayJsInterop when you need the value rather than rendered text:
string age = await DayJs.FromNow(article.PublishedAt);
string duration = await DayJs.DurationHumanize(TimeSpan.FromMinutes(90));
FromNow, ToNow, and SubscribeRelative require LoadRelativeTime. DurationHumanize requires LoadDuration. To pass an IANA timezone such as America/Chicago to the relative-time methods, enable both LoadUtc and LoadTimezone.
SubscribeRelative returns an IAsyncDisposable; retain and dispose it when its owner is disposed:
DayJsSubscription subscription = await DayJs.SubscribeRelative(
article.PublishedAt,
TimeSpan.FromMinutes(1),
value => relativeText = value);
await subscription.DisposeAsync();
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- Soenneker.Asyncs.Initializers (>= 11.0.153)
- Soenneker.Blazor.Extensions.IJSObjectReferences (>= 11.0.13)
- Soenneker.Blazor.Utils.ResourceLoader (>= 11.0.1907)
- Soenneker.Lepton.Suite (>= 11.0.167)
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 |
|---|---|---|
| 11.0.332 | 46 | 12/4/2026 |
| 11.0.331 | 49 | 12/4/2026 |
| 11.0.330 | 56 | 12/4/2026 |
| 11.0.329 | 51 | 12/3/2026 |
| 11.0.328 | 57 | 12/3/2026 |
| 11.0.327 | 74 | 12/2/2026 |
| 11.0.326 | 69 | 12/2/2026 |
| 11.0.325 | 65 | 12/2/2026 |
| 11.0.324 | 90 | 12/1/2026 |
| 11.0.323 | 94 | 11/30/2026 |
| 11.0.322 | 97 | 11/30/2026 |
| 11.0.321 | 98 | 11/29/2026 |
| 11.0.320 | 99 | 11/25/2026 |
| 11.0.319 | 99 | 11/19/2026 |
| 11.0.318 | 94 | 11/19/2026 |
| 11.0.317 | 102 | 11/19/2026 |
| 11.0.316 | 96 | 11/19/2026 |
| 11.0.315 | 97 | 11/19/2026 |
| 11.0.314 | 90 | 11/19/2026 |
| 11.0.313 | 95 | 11/19/2026 |
Update dependency Soenneker.Lepton.Suite to 11.0.167 (#999)