Skip to content

Project config

Create one config file at the project root:

  • layeron.config.ts
  • layeron.config.mts
  • layeron.config.js
  • layeron.config.mjs
Terminal window
import { project } from "@layeron/core"
export default project({
app: "./src/app.ts",
})

Use backends when one Layeron project has several backend entry files:

Terminal window
import { project } from "@layeron/core"
export default project({
backends: {
api: "./src/api.ts",
admin: "./src/admin.ts",
jobs: "./src/jobs.ts",
},
})

All backend entries in the same project compile into one project resource graph for the selected environment. Equal module declarations such as db({ name: "main", ... }) or storage.bucket({ name: "images" }) share the same logical resource. Routes and handlers from every backend entry run in the same generated app Worker.

Each backend entry must use the same backend({ project }) slug. Use app for one backend entry or backends for named backend entries.

See Multiple backends for the compile model, shared resource rules, and split guidance.

Create a Layeron project config.

Terminal window
project(options: ProjectOptions): LayeronProject

Options accepted by project(…) in layeron.config.ts.

FieldTypeRequiredDescription
appstring | undefinednoPath to the backend app entry, relative to the project root.
backendsRecord<string> | undefinednoNamed backend app entries, relative to the project root. All entries compile into one project resource graph.
envLayeronProjectEnvConfig | undefinednoNon-secret runtime values by environment.
Terminal window
env: {
defaults?: Record<string, string | number | boolean>
[environment: string]: Record<string, string | number | boolean> | undefined
}

Example:

Terminal window
export default project({
app: "./src/app.ts",
env: {
defaults: {
API_BASE_URL: "https://api.example.com",
FEATURE_CHECKOUT: false,
},
prod: {
FEATURE_CHECKOUT: true,
},
},
})

Use Env for runtime value behavior.