---
title: "Getting started with OneApp"
url: https://recursiveai.org/oneapp/docs/getting-started/
description: "Make a desktop app from the dotnet new template, run it, and drive it from the command line. Then run the same component in a browser. This guide was run…"
version: "1.0.0"
---

# Getting started with OneApp

Make a desktop app from the `dotnet new` template, run it, and drive it from the command line. Then run the same component in a browser. This guide was run on the OneApp 1.0.0 packages from NuGet with the .NET 10 SDK on Ubuntu 26.04: the window on X11 (a virtual display, Vulkan on an NVIDIA GPU), the browser part in headless Chrome.

## Make an app

You need the .NET 10 SDK. Install the template and make an app:

```shell
dotnet new install RecursiveAI.OneApp.Templates@1.0.0
dotnet new oneapp -n MyApp
cd MyApp
dotnet tool restore
```

`MyApp.csproj` references `RecursiveAI.OneApp` and `RecursiveAI.OneApp.Kit` 1.0.0 and nothing else, and `dotnet tool restore` installs the `oneapp` tool from the app’s tool manifest. The window’s page is one component, a template and a partial class with the same name, built from the kit.

`MainPage.html`:

```html
<Theme>
  <main class="page">
    <Card>
      <CardHeader>
        <CardTitle>Hello, {Name}</CardTitle>
        <CardDescription>Edit MainPage.html and MainPage.cs to change this window.</CardDescription>
      </CardHeader>
      <CardContent>
        <div class="field">
          <Label For="name">Your name</Label>
          <Input Id="name" Value="{Name}" OnValueChange="{v => Name = v}" Placeholder="World" />
        </div>
      </CardContent>
      <CardFooter>
        <Button Id="count" OnClick="{() => Clicks++}">Clicked {Clicks} times</Button>
      </CardFooter>
    </Card>
  </main>
</Theme>
```

`MainPage.cs`:

```csharp
using OneApp.Kit;
using OneUI.Components;

namespace MyApp;

/// <summary>The window's page: a greeting card with a name field and a counter button.</summary>
public partial class MainPage
{
    [State]
    private partial string Name { get; set; }

    [State]
    private partial int Clicks { get; set; }

    /// <inheritdoc />
    protected override void OnMounted()
    {
        Name = "World";
    }
}
```

`Program.cs` creates the app host with the component as its root and runs the loop until the window closes:

```csharp
using MyApp;
using OneApp;

// The development harness (`oneapp run`, `oneapp click ...`) is on in Debug builds and compiled out of Release builds.
// `--headless` runs without a window or GPU, for driving the app through the harness only.
bool headless = args.Contains("--headless");

using var host = AppHost.Create(new AppOptions(new MainPage())
{
    Title = "MyApp",
    AppId = "dev.example.myapp",
    Width = 480,
    Height = 360,
    Backend = headless ? OnePlatform.PlatformBackendKind.Headless : OnePlatform.PlatformBackendKind.Auto,
    UseGpu = !headless,
});

host.Run();
return 0;
```

The markup compiler in [OneUI](https://recursiveai.org/oneui/) checks every binding, event and CSS property when the project builds, so a misspelled name is a build error. The window itself comes from [OnePlatform](https://recursiveai.org/oneplatform/).

## Run it

```shell
dotnet run
```

A 480 by 360 window titled MyApp opens, with the card and the counter button.

## Drive it from the command line

`dotnet oneapp run . --detach` builds and starts the app in Debug, where it listens for the `oneapp` tool on a local socket; a Release build has no listener. The other commands talk to the running app and print JSON.

```shell
dotnet oneapp run . --detach
dotnet oneapp call status
dotnet oneapp click '#count'
dotnet oneapp click '#count'
dotnet oneapp type Ada --into '#name' --clear
dotnet oneapp query '#count'
dotnet oneapp capture --out window.png
```

`call status` printed:

```json
{"pid":3404732,"backend":"X11","gpu":true,"presenter":"gpu","presentedFrames":1,"pageCreations":1,"accessibility":{"state":"active"},"animating":false,"viewport":{"width":480,"height":360,"scale":1},"focused":null}
```

`query '#count'` answers with each matching element: its tag, id, classes, text, attributes, bounds and states. Before the clicks its text was `"Clicked 0 times"`; after them, `"Clicked 2 times"`. The title then read `"Hello, Ada"`. The clicks and the typing go through the window’s own event queue, as a mouse and keyboard would. `capture` wrote this:

![The MyApp window: a card titled “Hello, Ada” with the name field holding “Ada” and a button reading “Clicked 2 times”](https://recursiveai.org/oneapp/myapp-x11.png)

The [test harness](https://recursiveai.org/oneapp/docs/harness/) lists every command, and the same commands are offered to any tool that speaks MCP (`dotnet oneapp mcp`).

## The same component in a browser

`RecursiveAI.OneApp.Browser` registers a component as a custom element on `browser-wasm`; the browser does the layout and drawing. Make a folder `MyApp.Web` next to `MyApp`, copy `MainPage.html`, `MainPage.css` and `MainPage.cs` into it, and add these three files.

`MyApp.Web.csproj`:

```xml
<Project Sdk="Microsoft.NET.Sdk.WebAssembly">

  <PropertyGroup>
    <TargetFramework>net10.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <InvariantGlobalization>true</InvariantGlobalization>
    <WasmFingerprintAssets>false</WasmFingerprintAssets>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="RecursiveAI.OneApp.Browser" Version="1.0.0" />
    <PackageReference Include="RecursiveAI.OneApp.Kit" Version="1.0.0" />
  </ItemGroup>

</Project>
```

`Program.cs`:

```csharp
using System.Runtime.Versioning;
using MyApp;
using OneApp.Browser;

[assembly: SupportedOSPlatform("browser")]

BrowserApp.Define("my-app", _ => new MainPage());
```

`wwwroot/index.html`:

```html
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>MyApp</title>
</head>
<body>
  <my-app></my-app>
  <script type="module">
    import { boot } from './oneui-browser.js';
    await boot();
  </script>
</body>
</html>
```

Publish it (the `wasm-tools` workload must be installed) and serve the folder with any static file server:

```shell
dotnet publish -c Release -o out
cd out/wwwroot
python3 -m http.server 8080
```

`out/wwwroot` holds `index.html`, `oneui-browser.js`, which the package’s build step copies in, and `_framework/`. In Chrome, the element rendered the same card. Two clicks on the button and “Ada” entered in the field gave the same result as in the window:

![The same card in Chrome: “Hello, Ada”, the name field holding “Ada” and a button reading “Clicked 2 times”](https://recursiveai.org/oneapp/myapp-browser.png)

## Next

- [The dotnet new template](https://recursiveai.org/oneapp/docs/templates/): its files and options.
- [Component kit](https://recursiveai.org/oneapp/docs/kit/): the components, their parameters and the theme tokens.
- [Desktop shell](https://recursiveai.org/oneapp/docs/shell/): more windows, dialogs, overlays, menus, tray, notifications, file dialogs and hotkeys.
- [Packaging](https://recursiveai.org/oneapp/docs/packaging/): `oneapp install`, `.deb`, AppImage, `.app` and `.dmg`, `.msix`, and signing.
