Blazorade Core
Blazorade Core provides foundational building blocks that are shared across Blazorade libraries. It includes reusable component base functionality, utility components, JavaScript interop helpers, and client-side services for common Blazor scenarios.
If you are building your own Blazor component library or application features that rely on dynamic attributes, callback-based interop, or client browser utilities, Blazorade Core gives you strongly typed primitives so you do not need to rebuild those patterns from scratch.
Getting Started
1. Install the NuGet package
Install Blazorade.Core in your Blazor project.
2. Add common imports
Add the following to your _Imports.razor file:
@using Blazorade.Core.Components
@using Blazorade.Core.Components.Builder
@using Blazorade.Core.Services
@using Blazorade.Core.Components.Server
Blazorade.Core.Components.Server is only needed for Blazor Server scenarios.
Components
BlazoradeComponentBase
BlazoradeComponentBase is the base class for Blazor components in Blazorade Core. It helps you manage free-form attributes, CSS classes, inline styles, and child content in a consistent way.
Key capabilities include:
- Capturing unmatched attributes through
Attributes - Managing CSS classes through
AddClasses(...)andRemoveClass(...) - Managing inline styles through
AddStyle(...)andRemoveStyle(...) - Supporting templated content via
ChildContent
Use this base class when you are building reusable components that should be easy to customize from markup.
Read more: BlazoradeComponentBase wiki article
Redirect
Redirect navigates the user to another URL when the component renders. It is commonly used in authorization flows, for example redirecting unauthenticated users to sign-in.
Parameters:
Url(string): target URLDelay(int?): optional delay in milliseconds before redirecting
Read more: Redirect wiki article
ComponentReconnectModal (Blazor Server)
ComponentReconnectModal lets you customize reconnect UI shown when a Blazor Server app loses connection to the server.
It supports template-based customization for:
- Reconnecting state
- Reconnect failed state
- Reconnect rejected state
Because this UI appears when the server is unavailable, templates should stay informational and avoid interactive behavior that depends on server-side rendering.
Read more: ComponentReconnectModal wiki article
JavaScript Interop Helpers
DotNetInstanceMethod
DotNetInstanceMethod wraps a .NET instance method so JavaScript can call it back. This is useful when a JavaScript API uses callbacks rather than directly returning a value.
This type implements IDisposable. Dispose instances when done to avoid leaks.
Read more: DotNetInstanceMethod wiki article
DotNetInstanceCallbackHandler<T>
DotNetInstanceCallbackHandler<T> is designed for callback-driven interop workflows where your .NET code calls JavaScript and then awaits either a success callback or a failure callback.
Highlights:
- Supports both
IJSRuntimeand imported JS modules - Exposes
GetResultAsync(...)for awaited completion - Supports timeout control (default 3000 ms)
- Throws
FailureCallbackExceptionwhen JS signals failure
Like DotNetInstanceMethod, this class implements IDisposable and should always be disposed.
Read more: DotNetInstanceCallbackHandler wiki article
DotNetInstanceCallbackArgs
DotNetInstanceCallbackArgs is the argument payload used by DotNetInstanceCallbackHandler<T> when calling JavaScript. It contains:
SuccessCallbackFailureCallbackData(custom payload dictionary)
Read more: DotNetInstanceCallbackArgs wiki article
FailureCallbackException
FailureCallbackException is thrown when JavaScript invokes the failure callback. Its Result property contains the payload sent from JavaScript.
Read more: FailureCallbackException wiki article
Services
BlazoradeLocalizationService
BlazoradeLocalizationService provides localization-related values that are only available on the client.
Methods:
GetClientTimezoneOffsetAsync()GetClientDateTimeAsync()
Read more: BlazoradeLocalizationService wiki article
BlazoradeScrollService
BlazoradeScrollService provides utility methods for scrolling elements into view.
Methods:
ScrollIntoViewAsync(ElementReference component)ScrollIntoViewAsync(string elementId)
Read more: BlazoradeScrollService wiki article
Practical Guidance
- Always dispose interop helper instances (
DotNetInstanceMethod,DotNetInstanceCallbackHandler<T>) when complete. - If your JavaScript callback flow can fail, catch
FailureCallbackExceptionand inspectResult. - If a callback might never be triggered, configure a timeout in
GetResultAsync(...)and handle timeout exceptions in your workflow.