use-js-interop

use-js-interop is a skill for Claude Code, Codex from managedcode/dotnet-skills. It costs 114 tokens per session (2,599 once invoked), scanned A, a copy of use-js-interop, MIT.

A Blazor skill for connecting .NET components and JavaScript through collocated modules and typed interop wrappers.

In plain words
What is it for?
It helps add, review, or fix calls between JavaScript and .NET, including IJSRuntime, component references, module disposal, and browser lifecycle handling.
Why use it?
It helps avoid common timing, lifecycle, prerendering, and cleanup errors when JavaScript and Blazor code communicate.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit It helps add, review, or fix calls between JavaScript and .NET, including IJSRuntime, component references, module disposal, and browser lifecycle handling.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/managedcode/dotnet-skills/use-js-interop
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add managedcode/dotnet-skills --skill use-js-interop
Clone the repo
git clone --depth 1 https://github.com/managedcode/dotnet-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for use-js-interop

README.md
[![agentmods](https://agentmods.dev/badge/skills/managedcode/dotnet-skills/use-js-interop/github.svg)](https://agentmods.dev/skills/managedcode/dotnet-skills/use-js-interop)
Your own site
<a href="https://agentmods.dev/skills/managedcode/dotnet-skills/use-js-interop"><img src="https://agentmods.dev/badge/skills/managedcode/dotnet-skills/use-js-interop/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for use-js-interop

Your own site · 80×15
<a href="https://agentmods.dev/skills/managedcode/dotnet-skills/use-js-interop"><img src="https://agentmods.dev/badge/skills/managedcode/dotnet-skills/use-js-interop.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 114 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,599 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin 100% copy Near-identical to another mod in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00114 $0.02599
Opus 5.5 $0.00046 $0.01040
Sonnet 5.5 $0.00023 $0.00520
Haiku 4.5 $0.00011 $0.00260

Measured 2mo ago against content hash 6bf1227510ef, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

use-js-interop scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

This is a copy

100% identical to use-js-interop — 0 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

catalog/Frameworks/Official-DotNet-Blazor/skills/use-js-interop/SKILL.md · 320 lines

How it starts

The opening of the file, as written. The whole thing — 320 lines — stays where its author put it; the contents beside it link to each section on GitHub.

JS Interop in Blazor

1. Collocated JS Modules

Always use collocated .razor.js files with export — never global window.* functions or <script> tags.

// ChartPanel.razor.js — placed next to ChartPanel.razor
export function initialize(canvas, dotNetRef) { /* ... */ }
export function updateData(points) { /* ... */ }
export function dispose() { /* ... */ }

Import paths: same project = "./Components/ChartPanel.razor.js", RCL = "./_content/{AssemblyName}/...".

2. Lifecycle Timing

All JS interop must happen in OnAfterRenderAsync or event handlers — never in OnInitialized, OnParametersSet, or constructors. JS is not available during server prerendering.

Use a typed interop wrapper (see Section 4) — never call InvokeAsync/InvokeVoidAsync with raw string literals:

private ChartInterop? _chart;

protected override async Task OnAfterRenderAsync(bool firstRender)
{
    if (firstRender)
    {
        _chart = new ChartInterop(JS);
        await _chart.InitializeAsync(_canvasRef);
    }
}

Parameter changes: set a flag in OnParametersSet, apply in OnAfterRenderAsync:

private bool _dataChanged;

protected override void OnParametersSet() => _dataChanged = true;

protected override async Task OnAfterRenderAsync(bool firstRender)
{
    if (firstRender) { /* init */ }
    else if (_dataChanged && _chart is not null)
    {
        _dataChanged = false;
        await _chart.UpdateDataAsync(DataPoints);
    }
}

Each JS interop call crosses the .NET-to-JS boundary (and in Blazor Server, the SignalR circuit). Batching applies in both directions — .NET→JS and JS→.NET.

.NET → JS: merge consecutive calls

If the C# side makes two or more JS calls in a row, combine them into one JS function:

// ❌ Two round-trips — theme and locale are always applied together
await _module.InvokeVoidAsync("applyTheme", theme);
await _module.InvokeVoidAsync("applyLocale", locale);

// ❌ Result of one call feeds into another — both can stay in JS
var token = await _module.InvokeAsync<string>("createAccessToken");
await _module.InvokeVoidAsync("storeToken", token);

Read the full file on GitHub · 320 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2mo ago First seen · 320 lines · 114 tokens per session scan A 6bf1227510ef

Subscribe to this mod's changes

use-js-interop is a skill published in the GitHub repository managedcode/dotnet-skills (527 stars, last pushed 16d ago), licensed MIT. It adds 114 tokens to every session and 2,599 once invoked, about $0.0005 per session on Opus 5.5. A static security scan graded it A with 0 findings. It is 100% identical to use-js-interop, differing in 0 lines, and is treated as a copy.

Related

use-js-interop compared with skills from other repositories

use-js-interop next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
use-js-interopmanagedcode/dotnet-skillsSkill52716d agoMITA114Claude Code, Codex
codegenAterDev/Perigon.CLISkill544d agoApache-2.0A53Claude Code, Codex
i18nextyildizberkay/skillsSkill28mo agoApache-2.0A162Claude Code, Codex
database-orm-expertroedyrustam/vibes-plugSkill1293d agoMITA40Cursor
js-backend-expertroedyrustam/vibes-plugSkill1293d agoMITA48Cursor
rust-developmentnavikt/copilotSkill65yesterdayMITA27Claude Code, Codex
effect-tstenequm/skillsSkill392d agoMITA57Claude Code, Codex