Skip to content
Shiny PlatformShiny Platform
.NET MAUI on the WebRun your MAUI app in the browser on WebAssembly - real DOM elements, no Blazor. Try the web sample and the .NET MAUI GalleryGet started

Web (WebAssembly)

Platform.Maui.Web runs a MAUI app in the browser on WebAssembly. Every control is a real DOM element (<button>, <input>, <dialog>, SVG for shapes, a 2D canvas for GraphicsView), positioned by MAUI’s own layout engine. No Blazor, no Razor components, no canvas-drawn UI.

Frameworks
.NET MAUI
Operating Systems
Web

See it running: shinyorg.github.io/mauiplatforms and the .NET MAUI Gallery.

  • The .NET 11 SDK. No workload is needed (wasm-tools only if you opt into AOT).
  • Any modern browser to run the result.
MyApp.csproj
<Project Sdk="Microsoft.NET.Sdk.WebAssembly">
<PropertyGroup>
<TargetFramework>net11.0</TargetFramework>
<OutputType>Exe</OutputType>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<!-- Required by the [JSImport] interop the backend generates. -->
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<!-- Read at runtime by AppInfo. -->
<ApplicationTitle>My App</ApplicationTitle>
<ApplicationId>com.example.myapp</ApplicationId>
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Platform.Maui.Web" Version="*-*" />
<PackageReference Include="Platform.Maui.Web.Essentials" Version="*-*" />
</ItemGroup>
</Project>

The SDK is Microsoft.NET.Sdk.WebAssembly, not Microsoft.NET.Sdk.BlazorWebAssembly. Microsoft.Maui.Controls comes in through the Platform.Maui.Web package.

wwwroot/index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
<title>My App</title>
<link rel="icon" href="favicon.svg" />
<script type="module" src="./main.js"></script>
</head>
<body>
<div id="loading">Loading…</div>
</body>
</html>
wwwroot/main.js
import { dotnet } from './_framework/dotnet.js';
const { runMain } = await dotnet.create();
await runMain();
document.getElementById('loading')?.remove();

Use runMain(), not dotnet.run(): run() exits the runtime when Main returns, which would stop the app.

Program.cs
using Microsoft.Maui.Hosting;
using Microsoft.Maui.Platform.Web;
namespace MyApp;
public class MyWebApp : WebMauiApplication
{
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
public static class Program
{
public static Task Main() => new MyWebApp().RunAsync();
}
MauiProgram.cs
using Microsoft.Maui.Essentials.Web;
using Microsoft.Maui.Hosting;
using Microsoft.Maui.Platform.Web.Hosting;
namespace MyApp;
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiAppWeb<App>() // instead of UseMauiApp<App>()
.UseWebEssentials(); // optional: AppInfo, Preferences, Geolocation, ...
return builder.Build();
}
}

The app fills the whole page. To host it inside part of an existing page, override HostElementSelector in your WebMauiApplication with a CSS selector such as "#app".

Everything else is standard MAUI: XAML or C# pages, Shell, NavigationPage, bindings, styles, DisplayAlertAsync. Resources/Images, Resources/Fonts, Resources/Raw and Resources/AppIcon are picked up and served from the site root, as in a MAUI single project.

Terminal window
dotnet run # dev server; open the URL it prints
dotnet publish -c Release -o publish # static site in publish/wwwroot

Upload publish/wwwroot to any static host (GitHub Pages, Azure Static Web Apps, Netlify, S3/CloudFront, nginx).

  • .wasm must be served as application/wasm. Most hosts already do this.
  • Hosting under a subpath (https://example.com/myapp/)? Add <base href="/myapp/" /> to <head>.
  • Release builds are trimmed. Prefer compiled bindings (SetBinding(..., static (Item i) => i.Name)) over string paths.

Your MAUI styles style your views. The parts the backend draws itself (navigation bar, tab bar, flyout, dialogs) use CSS custom properties you can override in index.html:

<style>
html:root { --maui-accent: #0E7C66; --maui-font: "Inter", system-ui, sans-serif; }
</style>

Pages (ContentPage, NavigationPage, TabbedPage, FlyoutPage, Shell, modals), virtualized CollectionView and CarouselView, all the standard controls, layouts, shapes, GraphicsView and gestures. Add-on packages bring SkiaSharp (Platform.Maui.Web.SkiaSharp) and maps (Platform.Maui.Web.Maps, Leaflet + OpenStreetMap). Web backends for the Shiny CameraView and MediaElement are in the repository but not on NuGet yet.

Essentials covers AppInfo, DeviceInfo, Connectivity, Battery, DeviceDisplay, FileSystem, Preferences (localStorage), FilePicker, MediaPicker, TextToSpeech, Clipboard, Browser, Share, Launcher, Geolocation, motion sensors, Vibration and SemanticScreenReader. SecureStorage throws PlatformNotSupportedException: a browser has nowhere safe to keep secrets.

See the repository readme for the full handler table and the web backend guide for how rendering, layout and threading work.

SkiaSharp.Views.Maui ships view handlers for the native platforms only, so Platform.Maui.Web.SkiaSharp provides SKCanvasView for the web. Reference it next to Platform.Maui.Web and call UseSkiaSharpWeb() instead of UseSkiaSharp():

<PackageReference Include="Platform.Maui.Web.SkiaSharp" Version="*-*" />
builder
.UseMauiAppWeb<App>()
.UseSkiaSharpWeb(); // namespace Microsoft.Maui.Platform.Web.Hosting

Skia itself (SkiaSharp.NativeAssets.WebAssembly) is linked into the app’s dotnet.native.wasm, so the app needs the wasm-tools workload and every build relinks the native runtime. The package turns this on for you.

  • SKCanvasView renders into a raster surface at the device pixel ratio, and each frame is copied onto a <canvas> in one interop call. It supports PaintSurface, InvalidateSurface (at most one paint per animation frame, and none while the view is off screen), CanvasSize, IgnorePixelScaling, and EnableTouchEvents with Touch for mouse, touch and pen (pointer ids, buttons, pressure, wheel). A handled press captures the pointer and stops the browser from scrolling.
  • Not supported yet: SKGLView (WebGL) and the SKImageImageSource family of image sources.
  • Skia on the web has no system fonts. Load typefaces with SKTypeface.FromStream, for example from a MauiAsset.

Microsoft.Maui.Controls.Maps ships map handlers for the native platforms only, so Platform.Maui.Web.Maps provides MAUI’s own Map control for the web, drawn by Leaflet. App code written against Map, Pin, Polygon, Polyline and Circle runs unchanged. Reference the package next to Platform.Maui.Web and call UseMauiMapsWeb() instead of UseMauiMaps():

<PackageReference Include="Platform.Maui.Web.Maps" Version="*-*" />
builder
.UseMauiAppWeb<App>()
.UseMauiMapsWeb(); // namespace Microsoft.Maui.Platform.Web.Hosting

No API key is needed. Leaflet and Leaflet.markercluster are bundled in the package and load when the first map appears, so apps without a map don’t download them. Tiles come from OpenStreetMap (Street) and Esri World Imagery (Satellite, and Hybrid with Esri’s labels). Both have usage policies, and OpenStreetMap’s public servers are for light use, so point a busy app at a commercial or self-hosted tile service:

builder.UseMauiMapsWeb(options =>
{
options.StreetTiles = new WebMapTileLayer(
"https://tiles.example.com/{z}/{x}/{y}.png",
"&copy; Example Maps, &copy; OpenStreetMap contributors") { MaxZoom = 20 };
});
  • Supported: MapType (Street, Satellite, Hybrid), IsScrollEnabled, IsZoomEnabled, MoveToRegion (animated or not) and VisibleRegion, which follows the user’s panning and zooming. Pins support Label, Address, ImageSource (URI, file, font and stream images), MarkerClicked, InfoWindowClicked, ShowInfoWindow and HideInfoWindow, with live changes to any of these. Also polylines, polygons and circles (stroke, fill, IsVisible, ZIndex and click events), MapClicked, MapLongClicked (long press, or right click on desktop), IsShowingUser with UserLocationChanged (the browser’s geolocation), and IsClusteringEnabled with ClusteringIdentifier, ClusterClicked and custom cluster images (ClusterImageSource / ClusterImageProvider).
  • Not supported: IsTrafficEnabled (there is no keyless traffic layer) and MapStyle (Google Maps style JSON).
  • The browser asks before sharing the user’s location, and only on HTTPS or localhost.