Blazor's .NET 10 introduces new JavaScript interop capabilities, specifically the `InvokeConstructorAsync` method, which allows C# code to instantiate JavaScript objects and hold typed references via `IJSObjectReference`. Previously, developers had to rely on `eval`, global `window` variables, and string-based invocations — approaches prone to code injection, memory leaks, and naming collisions. With the new API, each component gets its own JS object instance with a controlled lifecycle, cleaner parameter passing, and no memory leaks. Additionally, `GetValueAsync` and `SetValueAsync` methods enable reading and writing JS object properties directly from C#. The post demonstrates these improvements using a lightbox image gallery integrated with a Telerik Blazor Data Grid.

5m read timeFrom telerik.com
Post cover image
Table of contents
Understanding the Problem to SolveNew JavaScript Interop Features in Blazor 10The InvokeConstructorAsync MethodThe GetValueAsync and SetValueAsync MethodsConclusion

Sort: