# devlanes examples

> Small apps to clone and start, each a devlanes project with a README that walks through its start. Source: https://github.com/devlanes-run/examples

```sh
git clone https://github.com/devlanes-run/examples
cd examples/basics-hello-node
devlanes start
```

## Basics

Start here if devlanes is new to you.

### [Hello Node](https://devlanes.run/examples/basics-hello-node.md)

Start here: one TypeScript server that gets its port and HTTPS hostname from devlanes.

- Built with: TypeScript, Hono
- Needs: devlanes, Git, node
- Teaches: `run_script`, `hosts`, `ready.http`, `tasks.when: lane.create`, `global_env`
- Code: https://github.com/devlanes-run/examples/tree/main/basics-hello-node

### [Ready checks](https://devlanes.run/examples/basics-ready-checks.md)

Tell devlanes when each service is up, with an http, tcp, log or cmd ready check.

- Built with: TypeScript, Hono
- Needs: devlanes, Git, node, curl
- Teaches: `ready.http`, `ready.tcp`, `ready.log`, `ready.cmd`, `ready.http.host`, `hosts.host_header`, `templates`, `tasks.when: lane.create`, `devlanes debug why`, `devlanes wait`, `devlanes reload`
- Code: https://github.com/devlanes-run/examples/tree/main/basics-ready-checks

## Languages

Services written in Python, Rust, Java and Go.

### [Python and FastAPI](https://devlanes.run/examples/languages-python-fastapi.md)

Run a FastAPI app under uv behind the HTTPS proxy, and call other HTTPS services from it.

- Built with: Python, FastAPI, uvicorn, jinja, httpx
- Needs: devlanes, Git, uv
- Teaches: `run`, `run_script (pyproject.toml)`, `platform: python`, `tasks.when: lane.create`, `SSL_CERT_FILE`, `DEVLANES_ORIGINS`
- Code: https://github.com/devlanes-run/examples/tree/main/languages-python-fastapi

### [Rust and axum](https://devlanes.run/examples/languages-rust-axum.md)

Run the services of a Cargo workspace, with a ready timeout long enough for the first build.

- Built with: Rust, axum, askama, tokio, reqwest
- Needs: devlanes, Git, rust
- Teaches: `run_script (Cargo.toml)`, `ready.http.timeout`, `SSL_CERT_FILE`, `devlanes lane new`
- Code: https://github.com/devlanes-run/examples/tree/main/languages-rust-axum

### [Java with Maven and Spring Boot](https://devlanes.run/examples/languages-java-maven.md)

Run two Spring Boot apps from one Maven multi-module build, one calling the other over HTTPS with the devlanes CA trusted.

- Built with: Java, spring-boot, maven, thymeleaf
- Needs: devlanes, Git, java
- Teaches: `run_script (pom.xml)`, `preset: spring-boot`, `platform: java`, `hosts[].port`, `ready.http.timeout`, `services.<name>.public_url`
- Code: https://github.com/devlanes-run/examples/tree/main/languages-java-maven

### [Go and net/http](https://devlanes.run/examples/languages-go-api.md)

Run two Go programs from one module, one with go run and one rebuilt by air, and call one from the other over HTTPS.

- Built with: Go, net/http, html/template, air, task
- Needs: devlanes, Git, go, task
- Teaches: `run_script (go.mod)`, `run_script (Taskfile.yml)`, `SSL_CERT_FILE`, `lane.data_path`, `ready.http.timeout`, `devlanes lane new`
- Code: https://github.com/devlanes-run/examples/tree/main/languages-go-api

## Web

Browser apps and the APIs they call, behind the HTTPS proxy.

### [Frontend and API on one lane domain](https://devlanes.run/examples/web-frontend-api.md)

Point a React frontend at its lane's API, with CORS and a session cookie that work on the lane's domain.

- Built with: TypeScript, React, Vite, Hono
- Needs: devlanes, Git, node
- Teaches: `preset: vite`, `services.<name>.public_url`, `services.<name>.url`, `DEVLANES_ORIGINS`
- Code: https://github.com/devlanes-run/examples/tree/main/web-frontend-api

### [Next.js app with an HTTPS sibling API](https://devlanes.run/examples/web-next-app.md)

Run Next.js with the next preset and call an HTTPS API in the same lane from a server component.

- Built with: TypeScript, Next.js, React, Hono
- Needs: devlanes, Git, node
- Teaches: `preset: next`, `NODE_EXTRA_CA_CERTS`, `services.<name>.public_url`, `services.<name>.url`, `tasks.when: lane.create`, `devlanes lane new`, `--env`
- Code: https://github.com/devlanes-run/examples/tree/main/web-next-app

### [WebSockets and SSE](https://devlanes.run/examples/web-realtime-ws.md)

Serve WebSockets and server-sent events through the proxy, and give a service's second port its own hostname.

- Built with: TypeScript, Vite, Hono
- Needs: devlanes, Git, node
- Teaches: `self.ports.<name>`, `hosts[].port`, `devlanes debug freeze`, `devlanes exec`
- Code: https://github.com/devlanes-run/examples/tree/main/web-realtime-ws

### [Wildcard tenants](https://devlanes.run/examples/web-wildcard-tenants.md)

Serve every tenant on its own subdomain with a wildcard host, while exact hostnames and a fallback gateway take the rest.

- Built with: TypeScript, Hono
- Needs: devlanes, Git, node
- Teaches: `hosts wildcard`, `hosts.fallback`, `domain()`, `lanes.vars`, `tasks.when: lane.create`
- Code: https://github.com/devlanes-run/examples/tree/main/web-wildcard-tenants

### [Fake SMS and email providers per lane](https://devlanes.run/examples/web-provider-stubs.md)

Swap SMS and email providers for local fakes, so each lane's messages land in its own inbox.

- Built with: TypeScript, Hono
- Needs: devlanes, Git, node
- Teaches: `services.<name>.public_url`, `tags`, `devlanes stop`
- Code: https://github.com/devlanes-run/examples/tree/main/web-provider-stubs

## Frameworks

Dev servers that devlanes runs through a preset.

### [Cloudflare Workers](https://devlanes.run/examples/frameworks-wrangler-workers.md)

Run two Cloudflare Workers with the wrangler preset, joined by a service binding that resolves inside the lane.

- Built with: TypeScript, Cloudflare, Hono
- Needs: devlanes, Git, node
- Teaches: `preset: wrangler`, `wrangler.vars`, `wrangler.args`, `lane.data_path`, `lanes.hosts_file`, `hosts[].port`, `hosts.host_header`
- Code: https://github.com/devlanes-run/examples/tree/main/frameworks-wrangler-workers

### [Cloudflare Vite plugin per lane](https://devlanes.run/examples/frameworks-cloudflare-vite.md)

Run a React app and a Worker in one Vite server, with an inspector port and stored state of its own in each lane.

- Built with: TypeScript, Cloudflare, React, Vite, Hono
- Needs: devlanes, Git, node
- Teaches: `preset: vite`, `self.ports.<name>`, `hosts.host_header`, `DEVLANES_LANE_DATA`
- Code: https://github.com/devlanes-run/examples/tree/main/frameworks-cloudflare-vite

### [Quarkus with Gradle and Postgres per lane](https://devlanes.run/examples/frameworks-quarkus-gradle.md)

Run Quarkus dev mode from Gradle with its own Postgres container and debugger port in each lane.

- Built with: Java, Postgres, Docker, quarkus, gradle, qute
- Needs: devlanes, Git, java, docker
- Teaches: `run_script (build.gradle.kts)`, `preset: quarkus`, `self.ports.<name>`, `infra.per_lane`, `infra.setup`, `ready.http.timeout`
- Code: https://github.com/devlanes-run/examples/tree/main/frameworks-quarkus-gradle

## Infra

Databases and other containers, shared between lanes or one for each.

### [Shared Postgres with a database per lane](https://devlanes.run/examples/infra-postgres-shared.md)

Share one Postgres container between lanes and give each lane its own database, migrated on every start.

- Built with: TypeScript, Postgres, Docker, Hono
- Needs: devlanes, Git, node, docker
- Teaches: `infra.compose`, `infra.project_name`, `infra.setup`, `infra.teardown`, `lanes.vars`, `tasks.when`, `tasks.after`, `tasks.steps`, `tasks.confirm`
- Code: https://github.com/devlanes-run/examples/tree/main/infra-postgres-shared

### [Postgres per lane](https://devlanes.run/examples/infra-postgres-per-lane.md)

Give each lane its own Postgres container while Redis stays shared, and delete a lane's container together with its data.

- Built with: TypeScript, Redis, Postgres, Docker, Hono
- Needs: devlanes, Git, node, docker
- Teaches: `infra.per_lane`, `DEVLANES_COMPOSE_LANE_PROJECT`, `infra.setup`, `infra.teardown`, `lanes.vars`, `devlanes lane clean`, `devlanes debug freeze`
- Code: https://github.com/devlanes-run/examples/tree/main/infra-postgres-per-lane

### [Many datastores with a namespace per lane](https://devlanes.run/examples/infra-multi-database.md)

Share Postgres, Redis, ClickHouse, RabbitMQ and an S3 store across lanes, with a namespace in each one for every lane.

- Built with: TypeScript, ClickHouse, RabbitMQ, Redis, Postgres, Docker, Hono, rustfs, mailpit
- Needs: devlanes, Git, node, docker
- Teaches: `infra.setup`, `infra.teardown`, `infra.per_lane`, `infra.hosts`, `infra.hidden`, `infra.project_name`, `lanes.vars`
- Code: https://github.com/devlanes-run/examples/tree/main/infra-multi-database

### [Plain containers and external ports](https://devlanes.run/examples/infra-plain-containers.md)

Run containers without Compose, such as a mock OIDC provider for each lane, and route a hostname to a server you start yourself.

- Built with: TypeScript, OpenID Connect, Docker, Hono
- Needs: devlanes, Git, node, docker
- Teaches: `infra.containers`, `infra.hosts`, `infra.external`, `devlanes.local.yaml`, `devlanes exec`
- Code: https://github.com/devlanes-run/examples/tree/main/infra-plain-containers

## Workflows

How a team repository uses devlanes day to day.

### [Profiles and tags](https://devlanes.run/examples/workflows-profiles-tags.md)

Group the seven services of an npm workspace with tags and templates, and start a different set of them with each profile.

- Built with: TypeScript, Hono
- Needs: devlanes, Git, node
- Teaches: `tags`, `templates`, `extends`, `profiles`, `autostart`, `keep_awake`, `ready.log`, `lanes.main.services`
- Code: https://github.com/devlanes-run/examples/tree/main/workflows-profiles-tags

### [Queue workers per lane](https://devlanes.run/examples/workflows-queue-workers.md)

Run two replicas of a worker that has no port and finishes the job in hand before it stops.

- Built with: TypeScript, Redis, Vite, Docker, Hono
- Needs: devlanes, Git, node, docker
- Teaches: `replicas`, `replica.index`, `ready.log`, `keep_awake`, `stop.signal`, `pty`, `lanes.vars`, `infra.project_name`, `infra.teardown`, `tasks`, `devlanes run`
- Code: https://github.com/devlanes-run/examples/tree/main/workflows-queue-workers

### [pnpm workspace with turbo and a second project](https://devlanes.run/examples/workflows-pnpm-monorepo.md)

Run a pnpm and turbo monorepo with a service for each package, next to a second project in a subdirectory.

- Built with: TypeScript, pnpm, Turborepo, React, Vite, Hono
- Needs: devlanes, Git, node, pnpm
- Teaches: `run_script`, `templates`, `tags`, `preset: vite`, `tasks.when: lane.create`, `projects.<name>.services`, `devlanes -p`, `devlanes run`
- Code: https://github.com/devlanes-run/examples/tree/main/workflows-pnpm-monorepo

### [Dev servers and production builds from one folder](https://devlanes.run/examples/workflows-dev-and-prod.md)

Switch a lane between dev servers and a production build with a profile, and keep personal settings in devlanes.local.yaml.

- Built with: TypeScript, React, Vite, Hono
- Needs: devlanes, Git, node
- Teaches: `profiles`, `run_scripts`, `extends`, `lane.data_path`, `autostart`, `devlanes --file`, `devlanes.local.yaml`, `devlanes debug config`
- Code: https://github.com/devlanes-run/examples/tree/main/workflows-dev-and-prod

### [Dotenv and one domain root](https://devlanes.run/examples/workflows-dotenv.md)

Read values from a gitignored .env that every worktree shares, and build each URL from the lane's domain.

- Built with: TypeScript, Hono
- Needs: devlanes, Git, node
- Teaches: `env.<NAME>`, `global_env`, `lane.domain`, `project.primary_path`, `devlanes reload`
- Code: https://github.com/devlanes-run/examples/tree/main/workflows-dotenv

### [From mprocs to devlanes](https://devlanes.run/examples/workflows-mprocs-migration.md)

Move a project from mprocs, Caddy and a hand-made port script to devlanes, one piece at a time.

- Built with: TypeScript, Shell, Caddy, Hono, mprocs
- Needs: devlanes, Git, node
- Teaches: `profiles`, `tags`, `tasks`, `tasks.after`, `hosts`, `self.port`, `lane.data_path`, `ready.log`, `keep_awake`, `devlanes debug top`
- Code: https://github.com/devlanes-run/examples/tree/main/workflows-mprocs-migration

### [Run tests against a lane with devlanes with](https://devlanes.run/examples/workflows-ci-with.md)

Wrap a test run in devlanes with, which starts a lane, gives the tests its HTTPS URLs and stops it afterwards.

- Built with: TypeScript, GitHub Actions, Vite, Hono, node:test
- Needs: devlanes, Git, node
- Teaches: `devlanes with`, `DEVLANES_PUBLIC_URL_<SERVICE>`, `profiles.run_scripts`, `tasks.profiles`, `devlanes exec`, `devlanes wait`
- Code: https://github.com/devlanes-run/examples/tree/main/workflows-ci-with

## Showcase

Larger stacks for trying the TUI and seeing failures.

### [A tour of the TUI](https://devlanes.run/examples/showcase-tui-tour.md)

Walk through the TUI key by key, on the same stack as the demo on devlanes.run.

- Built with: TypeScript, Redis, Postgres, React, Vite, Docker, Hono, mailpit
- Needs: devlanes, Git, node, docker
- Teaches: `devlanes`, `infra.per_lane`, `infra.hosts`, `infra.setup`, `infra.teardown`, `lanes.vars`, `tasks.after`, `profiles`, `autostart`, `ready.log`, `devlanes exec`, `devlanes debug freeze`
- Code: https://github.com/devlanes-run/examples/tree/main/showcase-tui-tour

### [Forty services and the start gate](https://devlanes.run/examples/showcase-many-services.md)

Start 40 services at once and watch the start gate queue them, with CPU and memory shown for each one.

- Built with: TypeScript, Hono
- Needs: devlanes, Git, node
- Teaches: `templates`, `tags`, `ready.log`, `startup`, `devlanes start --all-at-once`, `devlanes debug top`
- Code: https://github.com/devlanes-run/examples/tree/main/showcase-many-services

### [Services built to fail](https://devlanes.run/examples/showcase-broken.md)

Break services on purpose and read what devlanes and the proxy's error pages say about each failure.

- Built with: TypeScript, Hono
- Needs: devlanes, Git, node
- Teaches: `devlanes debug why`, `devlanes debug errors`, `devlanes config check`, `ready.http`, `ready: started`, `templates`, `profiles`, `proxy error pages`
- Code: https://github.com/devlanes-run/examples/tree/main/showcase-broken

## Remote

Lanes that run on another machine and open on yours.

### [Remote box in Docker](https://devlanes.run/examples/remote-docker-box.md)

Run lanes on a box inside a Docker container and open them from your machine under the same hostnames.

- Built with: Shell, Docker
- Needs: devlanes, Git, docker
- Teaches: `remote.boxes.<name>.command`, `devlanes daemon pair`, `devlanes remote connect`, `devlanes daemon revoke`, `hidden`, `sync`
- Code: https://github.com/devlanes-run/examples/tree/main/remote-docker-box

### [Remote SSH box](https://devlanes.run/examples/remote-ssh-box.md)

Prepare a Linux server as a devlanes box and connect to it over SSH, Tailscale or Cloudflare Tunnel.

- Built with: Shell, SSH, Tailscale, Cloudflare
- Needs: devlanes, Git, a linux box, ssh, node
- Teaches: `devlanes remote connect`, `devlanes daemon pair`, `devlanes remote ls`, `ports.range`
- Code: https://github.com/devlanes-run/examples/tree/main/remote-ssh-box
