aster.UI / Docs
Aster products
Showcase ↗

Aster UI / Guides

Get started with Aster UI

Run a complete project grid, inspect the code, and see where the data model takes responsibility. If you are evaluating the library, start with why Aster UI.

This example uses plain JavaScript and custom elements. The browser runs a local OData service in WebAssembly; no backend or account is needed to try it here.

Try the working example

Sort by a column heading or filter a column. The grid sends those query changes through its data context to the OData service.

Open the example on its own · Explore a connected grid and form

Run it locally

You need Git and Bun. The repository includes the prebuilt WebAssembly mock; rebuilding the server engine is not part of this introduction.

git clone https://github.com/getaster/aster-ui.git
cd aster-ui
bun install
bun run site
bun scripts/serve-static.ts dist-local/showcase --strict

Open http://localhost:4174/playground/first-grid.html. The built site is static; use an HTTP server rather than opening HTML through a file: URL, because the example fetches modules, metadata and WebAssembly.

The standalone distribution lives in dist-local/lib/. You can also copy that directory and the two example files into your own static site, preserving their relative paths. See installation and distribution for the files and TypeScript dependencies.

Start from the template

The Aster UI consumer template is a small standalone Bun project that installs the packages from npm. It connects a DataContext to the WebAssembly mock, compiles a YAML screen with @getaster/elements/yaml, and mounts it through the composition registry. Use it when you want a working npm application rather than the source checkout above.

Choose Use this template on the repository, or create a copy from a terminal:

gh repo create my-app --template GetAster/aster-ui-template --clone
cd my-app
bun install
bun run dev

Edit src/screen.ui.yaml for the screen and src/model.ts for its data and actions. The template's README lists the guide for each part and how to replace the mock with a real OData service.

The mock package ships its engine as wasm/odata_mock.wasm and exports it at @getaster/mock/wasm/odata_mock.wasm. A page asks for the root-relative odata_mock.wasm route, so a development or static server must serve that file there; the template's serve.ts and build.ts do. A real service removes the mock and the route.

The HTML shell

A theme supplies the visual tokens. The elements stylesheet supplies the controls. Importing the library module registers the custom elements. In an npm application, import one composed entry, for example @getaster/elements/styles/theme-lamplight.css; it includes the fonts, base primitives, element styles and the theme in the required order. The standalone distribution below keeps them as separate files.

<!doctype html>
<html lang="en">
<head><script type="importmap">{"imports":{"@getaster/data":"../lib/aster-ui.js","@getaster/elements":"../lib/aster-ui.js","@getaster/elements-preview":"../lib/aster-ui-preview.js","@getaster/elements-preview/rich-text":"../lib/aster-ui-rich-text.js","@getaster/data-navigator/model":"../lib/aster-data-navigator.js","@getaster/data-navigator":"../lib/aster-data-navigator.js","@getaster/mock":"../lib/aster-ui-mock.js","lit-html":"../lib/aster-ui.js","@preact/signals-core":"../lib/aster-ui.js"}}</script>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Aster UI — project grid</title>
  <link rel="stylesheet" href="../lib/themes/lamplight.css">
  <link rel="stylesheet" href="../lib/aster-ui.css">
  <style>
    body { margin: 0; padding: 16px; background: var(--aster-page); color: var(--aster-text); font: 14px/1.5 var(--aster-font-ui); }
    h1 { margin: 0 0 12px; font-size: 17px; }
  </style>
</head>
<body>
  <h1>Projects</h1>
  <div id="out" aria-live="polite">Loading the local OData service…</div>
  <script>try{const s=localStorage.getItem('aster-docs-scheme')||'system';document.documentElement.dataset.scheme=s==='system'?(matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light'):s}catch{}</script>
  <script type="module" src="./first-grid.js"></script>
</body>
</html>

Connect data and render the grid

The first section starts a local service with metadata and seed records. DataContext.connect() reads the metadata and creates the shared data context.

The grid names an entity set and a view. The view describes columns, sorting and filtering; the collection handles loading records for that query. CSS gives the virtualized grid a bounded height.

import { styles } from "@getaster/elements";
import { DataContext } from "@getaster/data";
import { html, render } from "lit-html";
import { createMockService } from "@getaster/mock";

const out = document.querySelector("#out");
try {
  // The local OData engine lets this example run without a backend.
  const json = async name => {
    const response = await fetch(`../lib/demo/${name}.json`);
    if (!response.ok) throw new Error(`Could not load ${name}`);
    return response.json();
  };
  const mock = await createMockService({
    metadata: await json("metadata"),
    data: await json("data"),
    wasm: new URL("../lib/odata_mock.wasm", import.meta.url),
  });
  const ctx = await DataContext.connect(mock.transport);

  render(html`
    <aster-grid
      .ctx=${ctx}
      .set=${"Projects"}
      .label=${"Projects"}
      .view=${{
        columns: [
          { field: "name" },
          { field: "state" },
          { field: "health" },
        ],
        sort: [{ field: "name" }],
        filters: {},
        frozen: 0,
      }}
      ${styles({ height: "300px" })}
    ></aster-grid>
  `, out);
} catch (error) {
  out.setAttribute("role", "alert");
  out.textContent = `The example could not load: ${error instanceof Error ? error.message : String(error)}. Reload to try again.`;
}

The html template’s dot syntax binds JavaScript properties: .ctx=${ctx} passes an object to the element. It does not serialize that object into an HTML attribute. The source imports html from lit-html and data APIs from @getaster/data; importing @getaster/elements registers the controls. The standalone HTML includes an import map that points those names to the shared browser distribution. In an npm application, your bundler resolves the same package imports. Keep one copy of Lit and signals so the controls and your application share their runtime.

What this example establishes

The small fixture demonstrates the contract. For larger results, collection paging and row virtualization use the same API. This example does not demonstrate save conflicts or cross-view editing; the connected views how-to introduces the edit model.

Connect your own service

Replace the mock setup with a fetch transport pointing to your OData service root:

import { DataContext, fetchTransport } from "../lib/aster-ui.js";

const ctx = await DataContext.connect(
  fetchTransport("https://your-service.example/odata")
);

Keep the rendering code, change Projects and its fields to match your metadata, and configure authentication and CORS for your deployment. The service must support the operations you enable. Metadata annotations drive field types, labels, validation and declared capabilities; see the shared data model.

Use Web Data metadata in the mock

Run the Web Data service, then export its metadata as JSON. Save it as src/metadata.json in the consumer template. In src/mock.ts, replace the hand-written metadata with the imported file and supply sample rows for the published sets. For the Web Data quickstart shop:

import metadata from "./metadata.json";

export { metadata };
export const seed = {
  Customer: [{ id: 1, name: "Ada Example", region: "EU" }],
  Order: [{ id: 10, customerId: 1, total: 120 }],
};

The template already passes both exports to createMockService. In src/model.ts, change the collection to Customer. In src/screen.ui.yaml, use the corresponding set and fields, such as name and region. Re-export the JSON when the Web Data model changes. The fixture rows stay in the app and you can edit them independently.

Continue building

Follow these guides in order to build on the running grid:

  1. Understand the shared data model: context, collections, selection and ownership.
  2. Connect a grid and form: use that model to keep selection, drafts and saved records in sync.
  3. Compose a workspace: connect reusable controls, actions and lazy views in JavaScript or YAML.

For specific controls and appearance: