Blazor

How to check whether the current app is Blazor server-side or web assembly?

How to check whether the current app is Blazor server-side or web assembly?

You can check whether the current app is Blazor server-side or web assembly using the “IJSInProcessRuntime” interface. In the following example, I have checked whether the app is a web assembly or server-side on button click.

<button @onclick="@onClick"> Click </button>

@code {

    [Inject]
    protected IJSRuntime jsRuntime { get; set; }

    private void onClick()
    {
        var isWebAssembly = this.jsRuntime is IJSInProcessRuntime;
    }
}
Sumitra Kumari Shaw

An Engineering graduate who Enjoys building things that live on the internet.