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;
}
}
Share with