Browse documentation
Fountain handbook

How Fountain extensions work

Learn how an extension package is put together, how a browser request travels from a forge page to an extension backend, and which responsibilities belong to the host.

On this page

Parts of a package

An installed package is a directory named after the extension ID:

hello/
├── extension.json
├── backend
└── assets/
    └── page.js
  • extension.json is the manifest. It declares the package identity, the executable, pages, panels, native capabilities and policies. Fountain validates it without running any code.
  • backend is the executable named by the manifest's executable field. The host starts it as a child process and talks to it over a private Unix socket.
  • assets/ holds the browser modules named by page and panel entry fields, plus anything they import. A package without pages or panels needs no assets.

See Package layout and manifest for the full field reference.

How a request reaches an extension

Browser code never talks to a backend directly. It calls the scoped helpers the host passes to its mount function, and Fountain decides whether to forward each request.

Path of an extension requestA browser module calls the host helpers. Fountain checks the session, scope and permissions, optionally asks the extension's authorizer, then forwards the request over a private Unix socket. The backend may call back into Fountain for native reads and operations, which the host checks again.request or streamNoYesnative callbackchecked against the sameadmissionBrowser modulein a forge pageFountain routesSession, scopeand permissionallowed?Not found orrefusedExtensionbackend on aprivate UnixsocketFountain nativeservicesExtension datadirectory
  1. A page or panel module calls request or stream with a path relative to its API base.
  2. Fountain requires a native signed-in browser session, matches the route to a running package, checks the contribution's scope and permission, and, when the package declares native.contribution.authorize, asks the package's authorizer.
  3. The host replaces anything the browser supplied with its own authority — extension, contribution, actor and, for repository pages, repository and permission — and forwards the request to the backend. Browser cookies and authorization headers are never forwarded.
  4. The backend reads that authority with the SDK. When it needs native data, it calls back into Fountain over a second private socket; each callback is checked against the request's private admission and the live session.

What the host owns and what the extension owns

Fountain The extension
Native routes, layout, navigation and account controls Labels and content inside its own mount root
Sign-in, sessions, account state and repository permissions Additional, endpoint-specific policy on every operation
Package validation, process start and stop, sockets and readiness Its application logic and HTTP interface
Native reads and conditional native writes, with their authorization Deciding what to read or request and why
Where the private data directory lives What is stored in it and how

Forgejo's database and internal services stay behind the host. Extensions reach native data only through the SDK's callbacks, and only for the capabilities they declare.

Two authority paths

Browser work and background work are authorized separately.

  • Browser session. Pages and panels act for the person signed in to the forge, for the duration of a request or stream. When the session ends or access is revoked, the host retires the mount and closes its streams.
  • Background. Work that runs without a browser uses the package's stable installation identity, an enrolled actor binding approved by an administrator and a native personal access token. Closing a browser tab neither grants nor revokes it. See Background collaboration.

Package states

Each package has a durable requested state — enabled or disabled — and a live state the host reports in site administration.

Extension package statesA disabled package moves to activating when enabled, then to enabled once its backend is ready. Disabling moves it through deactivating back to disabled. A failed start or stop leaves it failed until an administrator retries or disables it.EnableBackend readyStart failsDisableStoppedCleanup failsRetry enableDisabledisabledactivatingenabledfaileddeactivating

Private data survives every state change, including disabling, replacement and removal. See Install and manage packages.

Continue

Before installing anything, read the Extension trust model: extensions run as trusted code. Then enable extensions on your forge.