How LOCALHOST builds and runs an app. Every setting is optional: detection fills in the rest, and anything set here wins over it. Secrets never go in this file.
Put an lh.toml at the top of the repository and it wins over what the build detects: the folder, the build and start commands, the port, the health check, the starting size, which settings the app needs, the services it uses and what previews leave out. Every line is optional.
With a Dockerfile, the Dockerfile still builds the app and lh.toml only adds how to run it (build is ignored, with a note on the build page). Mistakes come back on the build page with their line number, and a problem that would stop the build is marked block.
lh init # writes lh.toml from what detection finds in this folder
lh check # the same checks the build runs, before you push
lh init sends file names, and the contents of build files only (package.json, pyproject.toml, Dockerfile and the like), to POST /builds/scan. Secret files such as .env and keys never leave your machine, and nothing sent is run.
| Key | Type | Meaning |
|---|---|---|
| folder | string | The folder inside the repository that holds the app, when it isn't the top. The site's folder setting, when set, wins. e.g. web, services/api |
| build | string | One command that builds the app (ignored when the repository has a Dockerfile). e.g. npm run build:prod |
| start | string | One command that starts the app. For a Rust workspace: the name of the program to run. e.g. node server.js, api |
| port | integer | The port the app listens on. It is also passed in as PORT. |
| health | string | A path that answers once the app is ready; traffic moves to a new version only after it does. e.g. /healthz |
| size | XS | S | M | L | The size a new site starts on. Changing the size of a running site is done in the panel. |
| Key | Type | Meaning |
|---|---|---|
| required | list of string | Settings the app can't run without. The site page lists the missing ones. |
| build_time | list of string | Settings the build needs too (NEXT_PUBLIC_*, VITE_* and the like). They end up in the built files, so never secrets. |
| defaults | table of string | number | boolean | Suggested values for settings that aren't secret. Anything that looks like a key, token or password stops the build. |
What the app needs besides itself. true adds one to what detection found, false takes it away.
| Key | Type | Meaning |
|---|---|---|
| postgres | boolean | |
| mysql | boolean | |
| redis | boolean |
| Key | Type | Meaning |
|---|---|---|
| enabled | boolean | false: no preview sites for pull requests, whatever the site's setting. |
| hide | list of string | Settings left out of previews (DATABASE_URL always is). |
The file has a JSON Schema at https://localhost.co.zw/developers/lh.schema.json. Editors that understand the #:schema comment complete keys and flag mistakes as you type:
#:schema https://localhost.co.zw/developers/lh.schema.json
[app]
port = 3000