LOCALHOST
All pages
Tools

lh.toml

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.

lh.tomloptional
[app] folder = "services/api" start = "api" # the program, in a Rust workspace port = 3000 health = "/healthz" [env] required = ["DATABASE_URL", "STRIPE_KEY"] build_time = ["NEXT_PUBLIC_SITE_URL"] [env.defaults] SHOP_CURRENCY = "USD" [services] postgres = true [previews] hide = ["STRIPE_KEY"]

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.

Secrets never go in this file. A default that looks like a key, token or password stops the build. Values belong on the site's settings page or lh env-set, where they're encrypted.

[app]

KeyTypeMeaning
folderstring 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
buildstring One command that builds the app (ignored when the repository has a Dockerfile). e.g. npm run build:prod
startstring One command that starts the app. For a Rust workspace: the name of the program to run. e.g. node server.js, api
portinteger The port the app listens on. It is also passed in as PORT.
healthstring A path that answers once the app is ready; traffic moves to a new version only after it does. e.g. /healthz
sizeXS | S | M | L The size a new site starts on. Changing the size of a running site is done in the panel.

[env]

KeyTypeMeaning
requiredlist of string Settings the app can't run without. The site page lists the missing ones.
build_timelist of string Settings the build needs too (NEXT_PUBLIC_*, VITE_* and the like). They end up in the built files, so never secrets.
defaultstable of string | number | boolean Suggested values for settings that aren't secret. Anything that looks like a key, token or password stops the build.

[services]

What the app needs besides itself. true adds one to what detection found, false takes it away.

KeyTypeMeaning
postgresboolean
mysqlboolean
redisboolean

[previews]

KeyTypeMeaning
enabledboolean false: no preview sites for pull requests, whatever the site's setting.
hidelist of string Settings left out of previews (DATABASE_URL always is).

For editors

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