/BlazorHistory

HTML5 History API Implementation for Blazor without any JavaScript.

Primary LanguageC#MIT LicenseMIT

BlazorHistory

HTML5 History API for Blazor without any JavaScript Library Dependency.

This package wraps HTML5 History APIs.

Installation

Install-Package BlazorHistory -Version 1.0.0

Register the service in your services method

services.AddBlazorHistoryService();

No javascript library reference dependency

This library has no javascript library reference dependency.

Usage

[Inject] IBlazorHistoryService BlazorHistory { get; set; }

BlazorHistory Methods

BlazorHistoryService Method
Goes to the previous page in session history Back()
Goes to the next page in session history Forward()
Loads a page from the session history by index Go(int index)
Pushes the given data onto the session history stack PushState(T stateData, string pageTitle, string url)
Updates the most recent entry on the history stack ReplaceState(T stateData, string pageTitle, string url)
Returns an Integer representing the number of elements in the session history, including the currently loaded page Length()
Allows web applications to explicitly set default scroll restoration behavior on history navigation. This property can be either auto or manual. ScrollRestoration(ScrollRestorationType scrollRestorationType)
Allows web applications to explicitly get default scroll restoration behavior on history navigation. This property can be either auto or manual. ScrollRestoration()
Returns a T type representing the state at the top of the history stack State()

License

MIT