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.
See it running: shinyorg.github.io/mauiplatforms and the .NET MAUI Gallery.
Requirements
Section titled “Requirements”- The .NET 11 SDK. No workload is needed (
wasm-toolsonly if you opt into AOT). - Any modern browser to run the result.
1. Project file
Section titled “1. Project file”<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.
2. Host page
Section titled “2. Host page”<!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>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.
3. Entry point and MAUI setup
Section titled “3. Entry point and MAUI setup”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();}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".
4. Write the app as usual
Section titled “4. Write the app as usual”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.
Run and publish
Section titled “Run and publish”dotnet run # dev server; open the URL it printsdotnet publish -c Release -o publish # static site in publish/wwwrootUpload publish/wwwroot to any static host (GitHub Pages, Azure Static Web Apps, Netlify, S3/CloudFront, nginx).
.wasmmust be served asapplication/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.
Theming the built-in chrome
Section titled “Theming the built-in chrome”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>What’s supported
Section titled “What’s supported”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
Section titled “SkiaSharp”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.HostingSkia 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 supportsPaintSurface,InvalidateSurface(at most one paint per animation frame, and none while the view is off screen),CanvasSize,IgnorePixelScaling, andEnableTouchEventswithTouchfor 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 theSKImageImageSourcefamily 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.HostingNo 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", "© Example Maps, © OpenStreetMap contributors") { MaxZoom = 20 };});- Supported:
MapType(Street, Satellite, Hybrid),IsScrollEnabled,IsZoomEnabled,MoveToRegion(animated or not) andVisibleRegion, which follows the user’s panning and zooming. Pins supportLabel,Address,ImageSource(URI, file, font and stream images),MarkerClicked,InfoWindowClicked,ShowInfoWindowandHideInfoWindow, with live changes to any of these. Also polylines, polygons and circles (stroke, fill,IsVisible,ZIndexand click events),MapClicked,MapLongClicked(long press, or right click on desktop),IsShowingUserwithUserLocationChanged(the browser’s geolocation), andIsClusteringEnabledwithClusteringIdentifier,ClusterClickedand custom cluster images (ClusterImageSource/ClusterImageProvider). - Not supported:
IsTrafficEnabled(there is no keyless traffic layer) andMapStyle(Google Maps style JSON). - The browser asks before sharing the user’s location, and only on HTTPS or localhost.

