Hello Node
A small TypeScript server built with Hono. devlanes gives it a port and routes https://example-hello-node.localhost to it. A second Git worktree runs a second copy as lane 1 at https://example-hello-node1.localhost. Start here if devlanes is new to you.
Requirements
Section titled “Requirements”- devlanes, with
devlanes setuprun once - Node 22 or later
Run it
Section titled “Run it”cd basics-hello-nodedevlanes startOn a terminal, devlanes start opens the TUI and follows the start there. devlanes start --no-ui prints the start as text:
example-hello-node@0 (main): 1/1 readyready web http://127.0.0.1:20400 https://example-hello-node.localhostOpen https://example-hello-node.localhost. The page says This is lane 0 of example-hello-node. and lists the lane, branch, service, port and URL that answered. https://example-hello-node.localhost/lane returns the same values as JSON.
During a start
Section titled “During a start”devlanes calls each worktree of the repository a lane. A fresh clone on main is lane 0, named main.
- The first start of a lane runs the
installtask (npm install), because a new worktree has nonode_modules. - devlanes reserves a block of ports for the lane and picks one for the
webservice. - It runs
npm run dev, which istsx watch src/index.ts, withPORTandHOST=127.0.0.1set. - The ready check requests
/healthzon that port until the server answers200 ok. Only then iswebready and the start done. - The proxy routes
https://example-hello-node.localhostto the port.
The page takes its URL from the X-Forwarded-Host header the proxy adds, so a request that skips the proxy shows not through the proxy there instead.
Try next
Section titled “Try next”devlanes statuslists the lane and the service:example-hello-nodeLANE BRANCH STATE SERVICES CPU MEM URL0 main running 1/1 0.0% 87.4 MiB https://example-hello-node.localhostdevlanes logs webprints what the server wrote:web#2 > devweb#3 > tsx watch src/index.tsweb#4web#5 hello-node listening on http://127.0.0.1:20400Edit the heading in
src/views/HomePage.tsxand save.tsx watchrestarts the server,devlanes logs webshows a[tsx] change in ... Restarting...line, and a reload of the page shows the change.devlanes url open webopens the page in your browser.Start a second lane:
git worktree add ../examples-checkout -b feat/checkout, thencd ../examples-checkout/basics-hello-node && devlanes start. Its page at https://example-hello-node1.localhost saysThis is lane 1 of example-hello-node., with another port and lane colour, while lane 0 keeps running.devlanes stopin this folder stops lane 0. Reload the page: the proxy answers with its ownService not runningpage (503,DL201 service-idle) and the command that starts the lane again.devlanes lane clean 0 --yesstops lane 0 and deletes its data and logs. Run it with1for the second worktree’s lane.
devlanes.yaml: theinstalltask and thewebservice withrun_script,hostsand the/healthzready check.src/index.ts: starts the server onPORTandHOST.src/env.ts: every variable the service reads, parsed once.src/app.tsx: the routes.src/views/: the page as JSX components.