NwUi.Primitives 0.18.0

dotnet add package NwUi.Primitives --version 0.18.0
                    
NuGet\Install-Package NwUi.Primitives -Version 0.18.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NwUi.Primitives" Version="0.18.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NwUi.Primitives" Version="0.18.0" />
                    
Directory.Packages.props
<PackageReference Include="NwUi.Primitives" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add NwUi.Primitives --version 0.18.0
                    
#r "nuget: NwUi.Primitives, 0.18.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package NwUi.Primitives@0.18.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=NwUi.Primitives&version=0.18.0
                    
Install as a Cake Addin
#tool nuget:?package=NwUi.Primitives&version=0.18.0
                    
Install as a Cake Tool

NetWasm.UI

A reflection-free, signal-driven C# UI framework for the browser, compiled ahead-of-time to WebAssembly with NetWasm. Inspired by Solid and Svelte rather than Blazor: components build their DOM once, fine-grained signals patch exactly the nodes that changed, and every state change crosses the Wasm→JS boundary at most once.

Website and live examples: matengo.github.io/NetWasm.UI, itself a NetWasm.UI app (source).

Status: 0.18, an early but usable release. The packages are on NuGet and the framework is tested in Chromium, Firefox and WebKit. The public API may still change in 0.x releases; every change is listed in the CHANGELOG. See Compatibility and versioning.

Get started in 30 seconds

You need the .NET SDK 10.0.3xx or 11.

dotnet new install NwUi.Templates
dotnet new netwasm-ui -o MyApp
cd MyApp
dotnet nwui-dev            # → http://localhost:8765, rebuilds and reloads on save

The template brings:

  • a router,
  • a C# component,
  • two .nwui pages,
  • CSS,
  • the nwui-dev dev server, as a local .NET tool.

Want an ASP.NET Core backend on the same origin? Use the hosted template (needs .NET 11). It creates a client, a server and a shared library, with prerendering and live reload:

dotnet new netwasm-ui-hosted -o MyApp
cd MyApp
dotnet watch --project MyApp.Server --no-hot-reload

Building a component library? dotnet new netwasm-ui-lib -o MyUi creates a headless library and its tests; see the component library tutorial.

Every template includes an AGENTS.md for AI coding agents; see AI coding assistants.

Read Getting started next.

Packages

All packages are on nuget.org and are released together with the same version number. Package IDs start with NwUi because the NetWasm. prefix on nuget.org belongs to the NetWasm toolchain; the namespaces are NetWasm.UI.

Package What it is Install
NwUi.Browser The package an app references: the browser host and the nwui.dom module. It brings in NwUi. dotnet add package NwUi.Browser
NwUi The core: signals, components, router, forms and the .nwui template compiler. Comes with NwUi.Browser.
NwUi.Templates dotnet new netwasm-ui, dotnet new netwasm-ui-hosted (ASP.NET Core) and dotnet new netwasm-ui-lib (component library). dotnet new install NwUi.Templates
NwUi.DevServer dotnet nwui-dev: publishes, serves (Brotli, SPA fallback) and live-reloads. In the template. Otherwise dotnet tool install --local NwUi.DevServer.
NwUi.AspNetCore Hosts the app in ASP.NET Core next to your API: MapNetWasmUI(), live reload and client publishing. See ASP.NET Core. dotnet add package NwUi.AspNetCore (in the server).
NwUi.Workers (preview) Typed C# Web Workers: a shared interface, AddWorker<T>() / AddWorkerPool<T>() and a source generator. See Web Workers. dotnet add package NwUi.Workers in the app, the worker and the contracts project.
NwUi.Primitives (preview) Headless components for design systems: disclosure, compound tabs, focus scope and roving focus. See Building a headless library. dotnet add package NwUi.Primitives in the component library or app.
VS Code: NetWasm.UI templates (.nwui) Syntax highlighting for .nwui. See below.

VS Code extension

The extension is not on the Marketplace yet. Install it from a GitHub release:

  1. Download nwui.vsix from the latest release.
  2. Run code --install-extension nwui.vsix. Or, in VS Code, open the Extensions view, click … and choose Install from VSIX….

To build it from source, see tools/vscode-nwui.

Quick look

You write components as .nwui templates (HTML with Razor-style @). A source generator compiles them at build time:

@* CounterView.nwui → public partial class CounterView : Component *@
<section>
    <h2>Counter</h2>
    <p>Count: <strong>@count</strong> &middot; doubled: @doubled</p>
    <button @onclick="() => count.Value++">+1</button>
    <button disabled="@(count.Value == 0)" @onclick="() => count.Value = 0">Reset</button>
    @if (count.Value >= 10) {
        <p class="hint">That's a lot of clicks!</p>
    }
</section>

@code {
    private readonly Signal<int> count = new(0);
    private Computed<int> doubled = null!;

    partial void OnInit() => doubled = new Computed<int>(() => count.Value * 2);
}

Prefer plain properties? [Reactive] puts a signal behind a partial property, in @code or any C# class (Reactive properties):

<button @onclick="() => Count++">Clicked @Count times</button>

@code {
    [Reactive] private partial int Count { get; set; }
}

You can also write components directly in C#, which is what the generator emits:

public sealed class CounterView : Component
{
    private readonly Signal<int> count = new(0);

    protected override Node Build()
    {
        var doubled = new Computed<int>(() => count.Value * 2);

        return Section(
            H2("Counter"),
            P("Count: ", Strong(Text(count)), " · doubled: ", Text(doubled)),
            Button(OnClick(() => count.Value++), "+1"),
            Button(Disabled(() => count.Value == 0), OnClick(() => count.Value = 0), "Reset"),
            When(() => count.Value >= 10, () => P("That's a lot of clicks!")));
    }
}

Size and speed

  • Size: the whole demo app (counter, todos, router, forms, nested components) is about 135 KB with Brotli, Wasm and JavaScript together. CI fails a pull request that grows it past its size budget.
  • Speed: in a js-framework-benchmark-style comparison, DOM updates are on par with SolidJS (0.85–1.07× its time; slowest when appending rows), and reactive and compute workloads are faster than Solid, most of them about 2× (up to 9× for compute). It is faster than React on every DOM case, and 3–36× faster than Blazor WebAssembly (interpreter) with a ~17× smaller download.
  • Startup: dotnet publish adds preload tags for the runtime modules and the Wasm to index.html, so everything downloads in parallel instead of one import level at a time. On ordinary broadband the demo app renders in about 315 ms instead of 700 ms. See Startup preloading. With NetWasmUIPrerender=true, the first screen of each listed page is rendered into its HTML at publish time, so content shows before the Wasm has loaded. See Prerendering.

Requirements

.NET SDK 10.0.3xx or 11.0.x (C# 15 needs 11). The NetWasm SDK is resolved from global.json.
NetWasm.Sdk 0.15.2, target framework net10.0-netwasm
Browsers Chrome/Edge 137+, Firefox 131+, Safari 18.4+ (needed for Wasm exception handling with exnref)

Licensing. NetWasm.UI is MIT. The NetWasm compiler and tools use the NetWasm Community License:

  • It is free for individuals, open source, education, and organisations with fewer than 250 employees and under USD 10 M in revenue.
  • Larger organisations need a sponsorship.
  • NetWasm's CoreLib and runtime are MIT, and the apps you build can use any license.

Check the current terms before you adopt it.

Try the samples

From a clone of this repository:

dotnet run --project tools/DevServer -- samples/Counter   # counter, todos, routing, forms, components
dotnet run --project tools/DevServer -- samples/Fetch     # HttpClient + System.Text.Json with Suspense
dotnet run --project tools/DevServer -- samples/Widgets   # several apps on one page
dotnet run --project tools/DevServer -- samples/Interop   # a JS library wrapped in a component
dotnet run --project tools/DevServer -- samples/Primitives # dialog, popover, tabs, disclosure, generic select and table
dotnet run --project tools/DevServer -- samples/Tsp       # route optimizer in a pool of Web Workers
dotnet run --project tools/DevServer -- site              # the project website
dotnet run --project samples/Hosted/Hosted.Server         # hosted in ASP.NET Core with an API

Documentation

AI coding assistants

NetWasm.UI is new, so AI models have not seen it in training. Give your assistant the docs:

  • AGENTS.md: projects created with dotnet new netwasm-ui, netwasm-ui-hosted and netwasm-ui-lib include an AGENTS.md with the rules agents most often get wrong.
  • Agent skill: copy skills/netwasm-ui to your project's .github/skills/ (GitHub Copilot) or .claude/skills/ (Claude Code).
  • Context7: assistants with the Context7 MCP server can look up the current docs and samples.
  • llms.txt: llms.txt indexes the guides, and llms-full.txt is all of them in one file.

AI coding assistants shows how to set each one up.

Repository layout

Path What
src/NetWasm.UI Core: reactivity, binary renderer, component/builder API, router, forms. Targets net10.0-netwasm, plus net10.0 for tests.
src/NetWasm.UI.Browser Browser host: [JSImport] bindings and the dom.mjs decoder. net10.0-netwasm only.
src/NetWasm.UI.Generator Roslyn source generator: *.nwui templates → Component partial classes. Ships inside the NwUi package.
src/NetWasm.UI.AspNetCore NwUi.AspNetCore: hosting in ASP.NET Core, live reload and client publishing.
src/NetWasm.UI.Primitives NwUi.Primitives: headless components (netstandard2.1): disclosure, compound tabs, focus scope.
samples/Counter Demo app: counter, todos, routing, nested routes, forms and /components.
samples/Fetch HttpClient + System.Text.Json with Resource and Suspense.
samples/Widgets Several independent apps (Wasm instances) on one page.
samples/Interop [JSImport], JSObject, callbacks and Promises: a JS library in a component.
samples/Primitives Reference components for a component library: dialog, popover, tabs, disclosure, generic select and data table.
samples/Primitives.Theme A design system on top of NwUi.Primitives: wrapper components and a stylesheet asset.
samples/Tsp Route optimizer (traveling salesman) in a pool of Web Workers; also on GitHub Pages at /tsp/.
samples/Hosted ASP.NET Core server with a weather API hosting a prerendered client; uses only the NuGet packages.
site/ The project website, built with NetWasm.UI and published to GitHub Pages.
templates/ The dotnet new netwasm-ui, netwasm-ui-hosted and netwasm-ui-lib template package.
tests/NetWasm.UI.Tests xunit tests against an in-memory FakeDomHost.
tests/NetWasm.UI.E2E Playwright browser tests against the samples (Chromium, Firefox, WebKit).
tools/DevServer nwui-dev: Kestrel dev server with Brotli, live reload and an error overlay.
tools/size-report Brotli/gzip size report and the budget check CI runs.
tools/vscode-nwui VS Code extension: .nwui syntax highlighting.
benchmarks/ Comparison with SolidJS, React and Blazor WebAssembly.

Known limitations

  • No reflection on NetWasm, so libraries that rely on it throw at run time. See Libraries and packages.
  • One app per Wasm module.
  • No server-side rendering (SSR) per request. Pages can be prerendered at publish time, but the app replaces that markup when it starts (no hydration yet), so handlers only work once the Wasm has loaded.
  • No hash routing; the server must fall back to index.html for app routes.
  • No hot reload; live reload takes ~3 s and keeps simple signal values and form state.
  • .nwui has syntax highlighting but no IntelliSense. Control flow is only @if/@foreach, and generic components need explicit type arguments (TItem="Fruit").

See Troubleshooting.

Contributing

See CONTRIBUTING.md for building, tests, the public API workflow and the roadmap. See CHANGELOG.md for what has changed.

License

MIT – see LICENSE.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  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 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.18.0 50 12/1/2026
0.17.0 144 11/25/2026