/JSRunner

Primary LanguageC#MIT LicenseMIT

JSRunner

Description

Allows you to write JS directly on your c# code

Example:

await js.Run("if(i % 10 == 0) alert(i)", new{ i });

You can also return a value:

i = await js.Run<int>(@"
i++
return i
", new{ i });

Installation

Install this nuget package

On your program.cs add

using JSRunner;

[...]

builder.Services.AddJSRunner();

In your blazor component that you want to run js code add

@using JSRunner;
@inject JS js;