Backend entry
The backend entry default-exports a backend(...) app.
import { backend } from "@layeron/core"
const app = backend({ project: "billing", compatibilityDate: "2026-05-24",})
export default appbackend(options)
Section titled “backend(options)”Create a Layeron backend app.
backend(options: BackendOptions): BackendAppbackend(...) parameters
Section titled “backend(...) parameters”Options accepted by backend().
| Field | Type | Required | Description |
|---|---|---|---|
project | string | yes | Stable project slug used for compilation, deployment state, and resource naming. |
name | string | undefined | no | Human-readable app display name. |
endpoint | string | undefined | no | App endpoint metadata recorded with the app spec. |
gateway | Layeron.Runtime.Gateway.GatewayConfig | undefined | no | Public Gateway runtime configuration. |
compatibilityDate | string | undefined | no | Cloudflare Workers compatibility date. |
compatibilityFlags | string[] | undefined | no | Cloudflare Workers compatibility flags. |
observability | Layeron.Observability.ObservabilityConfig | undefined | no | App-level observability policy. |
placement | Layeron.Common.Placement.LayeronPlacement | undefined | no | App-level placement defaults for compute, data resources, and Durable Objects. |
Common fields
Section titled “Common fields”project: stable project slug used for compilation and naming.gateway: public ingress policy, CORS, request ids, traces, and Gateway logs.compatibilityDate: Workers runtime compatibility version.compatibilityFlags: extra Workers runtime flags.observability: app-level logging, events, and trace policy.placement: app-level placement defaults for Workers compute, data resources, and Durable Objects.
Placement
Section titled “Placement”Use placement on backend(...) to set app-wide defaults. Use placement on
an individual product to override one product instance.
import { backend } from "@layeron/core"import { db, realtime, storage } from "@layeron/modules"
const app = backend({ project: "media", placement: { compute: { mode: "smart", locationHint: "weur", }, data: { locationHint: "weur", }, durableObjects: { locationHint: "weur", }, },})
const database = db({ name: "main", placement: { data: { locationHint: "enam", }, },})
const files = storage.bucket({ name: "uploads" })const rooms = realtime({ name: "rooms" })
app.use(database)app.use(files)app.use(rooms)
export default appProduct placement merges with backend placement by field. data applies to D1
and R2 resources. compute applies to Workers. durableObjects applies to
Durable Object namespaces and runtime stub selection.
Data placement accepts wnam, enam, weur, eeur, apac, and oc.
Compute and Durable Object placement also accept sam, afr, and me.
jurisdiction accepts eu and fedramp for data and Durable Object
placement.