Search⌘ K
AI Features

InvokeAsync

Explore how to use the InvokeAsync method of IJSRuntime in Blazor to call JavaScript functions asynchronously. Understand how to retrieve and use JavaScript return values within a Blazor component, demonstrated through a window size example.

We'll cover the following...

The InvokeAsync method is used when we want to call a JavaScript function that returns a value. It invokes the specified JavaScript function asynchronously.

This is the InvokeAsync method of IJSRuntime:

C#
ValueTask<TValue> InvokeAsync<TValue>(string identifier, params object[] args);

Just like the InvokeVoidAsync method, the first argument is the identifier for the JavaScript method, and the second argument ...