Avalonia for WebAssembly

Run your C# and XAML in the browser, on the real .NET runtime.

Platform support

Hosting

Static files

No server-side component is required. Any static host will do.

Rendering

Skia through CanvasKit

Drawn to a WebGL canvas, so there’s no DOM to fight.

Browsers

Anything with full WebAssembly

The docs defer to caniuse.com/wasm rather than pinning versions.

Runtime

.NET 8.0 or later

The real .NET runtime, the real base class library, in the tab.

Every tested OS version is published in the support matrix.

Running in this tab

This is Avalonia, compiled to WebAssembly

What opens is the Avalonia Charts control, running on the real .NET runtime in this tab. No plugin, no server rendering the frames, and no second UI stack.

The live demo runs on a desktop browser, where spending the download makes sense. Everything describing it below is the same on a phone.

What you get in the tab

The browser is a publish target, not a second front end.

WebAssembly is another head on the project you already maintain.

The view models, the styles, the custom controls and the validation rules are the ones your desktop build uses, because they’re literally the same assemblies.

  • No second UI stack
  • No second place to fix a bug
  • No second design system to keep matching
dotnet publish -c Release
# bin/Release/net8.0-browserwasm/publish/wwwroot

The real runtime, not a subset of it.

Avalonia on WebAssembly runs on the .NET runtime rather than on a translation layer, so the language and the library surface are the ones you already know. The wasm-tools workload is the whole toolchain.

  • System.Text.Json, HttpClient, LINQ and the rest of the BCL
  • NuGet packages, using the same package reference
  • The browser backend for .NET MAUI, too
dotnet workload install wasm-tools

Avalonia owns the canvas. The browser is still right there.

Drawing the interface ourselves is what makes the browser build match the desktop one. It doesn’t put the web platform out of reach when you actually want it.

  • JSImport pulls a JavaScript function into C#
  • JSExport hands a C# method back to the page
  • Screen readers, partially, through ARIA attributes
[JSImport("navigator.clipboard.writeText", "host")]
internal static partial Task CopyAsync(string text);

[JSExport]
internal static void OnDroppedFile(string name) =>
    Messenger.Send(new FileDropped(name));

Ahead of time, when you want the frames.

RunAOTCompilation compiles IL before it ships, trading a larger download for markedly faster execution. It’s the right trade for an application people keep open and the wrong one for a page they glance at.

  • Release builds trim automatically
  • Brotli typically reduces .wasm files by 60 to 70 percent
  • DevTools inspects the running browser build
<RunAOTCompilation>true</RunAOTCompilation>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

Getting it deployed

Static files, and one thing to plan for.

The build output is a wwwroot folder, and what it costs to deliver that folder is the part worth designing around.

  • Any static host. GitHub Pages, the nginx already running your main site, or any other static host you’ve got.

  • Cache it once per release. The payload is content-addressed and immutable, so long-lived cache headers move the cost from once per visit to once per deploy.

  • The honest part: first load. The demo higher up this page, which is AOT-compiled and bundles five controls, is about 13 MB over the wire after Brotli, measured on 2026-08-23.

  • Good fits. Internal tools, operator consoles, dashboards, demos of desktop software, and anything where a login already precedes the first screen.

Avalonia is MIT licensed, the browser head included.

Every target

The browser is the sixth target.

Nothing about the browser build is a separate codebase. It’s the desktop and mobile project with one more head added to the solution.

Avalonia for Windows

Direct Win32 calls, x64 and ARM64.

Avalonia for macOS

A native backend, universal binaries.

Avalonia for Linux

X11, Wayland, and bare framebuffer.

Avalonia for mobile

iOS and Android, from the same views.

Publish the same demo you just tried.

Add a browser head to an existing Avalonia project and publish the wwwroot folder to any static host. The framework is MIT licensed, and there’s no server to provision before people can use it.