---
title: "Browser pages"
url: https://recursiveai.org/oneplatform/docs/browser/
description: "The browser backend (PlatformBackendKind.Browser, chosen automatically on browser-wasm) draws into one canvas and reads input from the page. Its half in…"
version: "1.0.0"
source: https://github.com/recursive-ai-oss/oneplatform-csharp/blob/37f5a73c449624ea8671f8612d61000e2d57aa5e/docs/browser.md
---

# Browser pages

The browser backend (`PlatformBackendKind.Browser`, chosen automatically on `browser-wasm`) draws into one canvas and reads input from the page. Its half in JavaScript is `oneplatform.js`.

## Getting the script

`RecursiveAI.OnePlatform` ships `oneplatform.js` as a static web asset (the same mechanism a Razor class library uses for its scripts). An app built with `Microsoft.NET.Sdk.WebAssembly` (or the Blazor WebAssembly SDK) that references the package gets the file in its build and publish output, under the base path `_content/RecursiveAI.OnePlatform/`:

```
wwwroot/_content/RecursiveAI.OnePlatform/oneplatform.js
```

Nothing needs copying. In an app that serves its own folder, the file is served at `/_content/RecursiveAI.OnePlatform/oneplatform.js`.

## Registering it

The program's `[JSImport]`s name the module `oneplatform`, so the page registers the script under that name after creating the runtime and before running the program:

```html
<canvas id="oneplatform-canvas" style="width:100vw;height:100vh"></canvas>
<script type="module">
  import { dotnet } from './_framework/dotnet.js';
  import * as platform from './_content/RecursiveAI.OnePlatform/oneplatform.js';

  const runtime = await dotnet.create();
  runtime.setModuleImports('oneplatform', platform);
  await runtime.runMain();
</script>
```

Without the registration, creating the app fails with a JavaScript interop error that names the missing module.

## The canvas

The window is the canvas whose id is `PlatformOptions.DisplayName`, or `oneplatform-canvas` when that is null. It is sized to the visible part of the page and follows the device pixel ratio, and a page has exactly one window.

## Development control

`BrowserPage.SetControlHandler` lets a development build take control messages from the page's script: the page calls the exported `OnePlatform.BrowserPage.ControlAsync(message)` and gets the answer as text. A release build leaves the handler unset and the function answers with an error text.
