# Browser apps

The Browser project runs shared C# app code on .NET WebAssembly. A normal static web server can host the published assets; visitors do not need to install .NET.

## Run and publish

From a generated `MyApp` folder:

```sh
dotnet run --project MyApp.Browser.csproj -c Release
dotnet publish MyApp.Browser.csproj -c Release -p:RunAOTCompilation=false -o artifacts/browser
```

The development server prints its local URL. Publish places the deployable files under `artifacts/browser/wwwroot`. Deploy that directory's **contents**, including `_framework`, JavaScript, and fonts, not the project sources or the parent publish directory.

For a local static check, with Python 3 installed:

```sh
python3 -m http.server 5083 --directory artifacts/browser/wwwroot
```

Open `http://localhost:5083/`. Use HTTP rather than opening `index.html` as a local file.

## Check the real path

If the app will live under `/my-app/`, test that prefix too. Asset URLs must resolve below the deployed directory, and the trailing slash matters for relative URLs. Serve WebAssembly with `application/wasm` and JavaScript with a JavaScript MIME type. Inspect the network panel for missing fonts or framework files before debugging a blank canvas.

GitHub Pages can serve this static output. Deployment credentials, DNS, and the site's URL prefix belong to the hosting setup; publishing a project does not configure them.

## Choose AOT after the app works

The default development path uses the .NET interpreter/Jiterpreter. AOT compiles managed methods into WebAssembly at publish time and takes longer. It still uses .NET runtime services such as garbage collection and interop.

```sh
dotnet workload install wasm-tools
dotnet publish MyApp.Browser.csproj -c Release -p:RunAOTCompilation=true -p:WasmStripILAfterAOT=true -o artifacts/browser-aot
```

Compare startup size, loading time, and the interaction you care about before choosing a build mode. Browser GPU rendering requires WebGL 2 availability. Native extra windows, IME behavior, and trackpad phase information differ from desktop runtimes; design for those [capability boundaries](../platform-support/index.md).
