---
title: "Frontend"
manual: "adsum by web-vision"
version: "main"
permalink: "https://docs.typo3.org/permalink/web-vision/adsum-monorepo:extending-frontend@main"
source: "Extending/Frontend.rst"
rendered: "2026-11-07T02:01:32+00:00"
---

# Frontend {#extending-frontend}

Every package brings its own frontend, written in TypeScript. The core collects the frontends of all installed
packages into one import map. A package ships its built files, so an installation needs no Node.js.

## Declare the frontend {#declare-the-frontend}

A package with a `public/` directory and a `config/frontend.php` contributes a frontend. The file returns an
array:

```php
return [
    'imports' => [
        '@adsum/working-time/' => 'js/',
    ],
    'module' => '@adsum/working-time/main.js',
];
```

-   **`imports`**

    Maps an import prefix to a directory below `public/`. Every `.js` file in it is importable as
    `@adsum/<package>/<path>`.

-   **`module`**

    The entry module of the package. The core imports it on every page, after the translations are loaded.

-   **`styles`**

    Optional. Style sheets below `public/` added to every page, for example `css/main.css`.

-   **`importMaps`**

    Optional. Files below `public/` that contain further import map entries for built vendor modules.

-   **`favicon`**

    Optional. A file below `public/` used as the favicon.

The name of the package is the directory name without the `adsum-` prefix: the package in `adsum-working-time`
is `working-time`. Its `public/` directory is published as `/bundles/<name>/`.

## Files found by convention {#files-found-by-convention}

The core also reads two directories in `public/`:

-   `public/translations/<locale>.json`: the frontend catalogues, built from the XLIFF files of the package (see
    [Translations and Icons](https://docs.typo3.org/permalink/web-vision/adsum-monorepo:extending-translations-icons@main)).
-   `public/icons/<name>.svg`: the icons, usable by name in navigation entries and screens.

## Source layout in this repository {#source-layout-in-this-repository}

In this repository the sources live outside the package; Vite builds them into `public/` of the package.

```text
Build/Sources/TypeScript/<package>/   TypeScript, one JavaScript file per file
Build/Sources/Icons/<package>/        icons.json and own SVG icons
Build/Sources/Scss/<package>/         main.scss, built into css/main.css
packages/web-vision/adsum-<package>/public/   js/, icons/, translations/, css/
```

A package developed elsewhere ships its built `public/` directory in the same shape, built with any tool.

## Entry module {#entry-module}

The entry module registers the screens and defines the web components of the package. The entry module of the
attendance package:

```typescript
import './screens.js';
import { Clock } from './Clock.js';

if (customElements.get('tt-clock') === undefined) {
    customElements.define('tt-clock', Clock);
}
```

Importing `./screens.js` runs the `registerScreen()` calls (see [Screens](https://docs.typo3.org/permalink/web-vision/adsum-monorepo:extending-screens@main)).

## Web components {#web-components}

Components are Lit elements. `lit` and Web Awesome come from the import map; do not bundle them. Components use the
translations and the API client of the core. The clock of the attendance package, `<tt-clock>`, shortened:

```typescript
import { LitElement, html, nothing, type TemplateResult } from 'lit';
import { ApiClient } from '@adsum/core/api/ApiClient.js';
import { translate } from '@adsum/core/i18n/translations.js';

export class Clock extends LitElement {
    public static override properties = {
        status: { state: true },
    };

    public declare status: { state: string } | undefined;

    private readonly api = new ApiClient();

    public override connectedCallback(): void {
        super.connectedCallback();
        void this.reload();
    }

    protected override render(): TemplateResult | typeof nothing {
        return this.status === undefined ? nothing : html`<span>${translate(`clock.state.${this.status.state}`)}</span>`;
    }

    private async reload(): Promise<void> {
        this.status = await this.api.get<{ state: string }>('/me/clock');
    }
}
```

`ApiClient` has `get()`, `read()`, `post()`, `patch()`, `put()` and `delete()`. It prefixes `/api/v1`,
sends the session cookie and throws on error responses. `patch()`, `put()` and `delete()` take the ETag of the
resource as the option `ifMatch`.

## Icons in components {#icons-in-components}

Show an icon with Web Awesome's `wa-icon` and the icon library `adsum`:

```html
<wa-icon library="adsum" name="clock" aria-hidden="true"></wa-icon>
```
