Iskra.StdWeb
0.3.0
dotnet add package Iskra.StdWeb --version 0.3.0
NuGet\Install-Package Iskra.StdWeb -Version 0.3.0
<PackageReference Include="Iskra.StdWeb" Version="0.3.0" />
<PackageVersion Include="Iskra.StdWeb" Version="0.3.0" />
<PackageReference Include="Iskra.StdWeb" />
paket add Iskra.StdWeb --version 0.3.0
#r "nuget: Iskra.StdWeb, 0.3.0"
#:package Iskra.StdWeb@0.3.0
#addin nuget:?package=Iskra.StdWeb&version=0.3.0
#tool nuget:?package=Iskra.StdWeb&version=0.3.0
Iskra.StdWeb
Iskra.StdWeb provides strongly typed C# wrappers for standard browser APIs. The bindings are generated from WebIDL definitions and are intended for .NET WebAssembly applications that need direct access to the browser platform without a Blazor dependency.
What It Provides
- Generated wrappers for DOM, Fetch, Canvas, WebGL, Web Audio, WebRTC, and other standard Web APIs.
- Typed C# access to browser globals, interfaces, dictionaries, enums, callbacks, and events.
- Integration with Iskra.JSCore for proxy creation, type marshalling, JavaScript object lifetime, and callback interop.
- Generated code based on W3C WebIDL data from webref.
Quick Start
Create a browser WebAssembly project and add the package:
dotnet new wasmbrowser
dotnet add package Iskra.StdWeb
Initialize the StdWeb proxy factory before using generated browser types:
using System.Runtime.InteropServices.JavaScript;
using Iskra.JSCore;
using Iskra.StdWeb;
public static class Program
{
public static async Task Main()
{
await StdWebProxyFactory.InitializeAsync();
var window = JSObjectProxyFactory.GetProxy<Window>(JSHost.GlobalThis);
var document = window.Document;
var message = document.CreateElement("div");
message.TextContent = "Hello from C#!";
document.Body?.AppendChild(message);
var button = document.CreateElement("button");
button.TextContent = "Click me";
document.Body?.AppendChild(button);
button.AddEventListener("click", new EventListener(ev =>
{
window.Console.Log("Button clicked", ev.JSObject);
}), false);
await Task.Delay(Timeout.Infinite);
}
}
Common Patterns
Access browser globals through JSObjectProxyFactory:
var window = JSObjectProxyFactory.GetProxy<Window>(JSHost.GlobalThis);
var document = window.Document;
Cast created elements to their more specific generated type when you need type-specific members:
var input = (HTMLInputElement)document.CreateElement("input");
input.Value = "Initial value";
Keep callback objects alive for as long as JavaScript may invoke them. For one-off application-level handlers, assigning the callback to a field is usually the simplest approach.
Generation
The generated sources live under AutoGen and are produced by ../Iskra.WebIDLGenerator. The generator consumes curated WebIDL definitions from the repository's ../../submodules/webref submodule.
Examples
- ../../examples/Iskra.TodoExample creates and updates DOM nodes directly through StdWeb.
- ../../examples/Iskra.CanvasExample uses generated Canvas bindings for animation.
Requirements
- .NET 9.0 or later
- Browser with WebAssembly support
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Iskra.JSCore (>= 0.3.0)
-
net9.0
- Iskra.JSCore (>= 0.3.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Iskra.StdWeb:
| Package | Downloads |
|---|---|
|
Iskra.Core
Core framework for building reactive WebAssembly UIs with C# and .NET — component model, rendering, signals, and source generators. |
GitHub repositories
This package is not used by any popular GitHub repositories.