Run worktrees side by side
Run environments for different worktrees, each with separate ports, local URLs, and managed database data.
Worktree isolationStart your frontend, API, and databases on your machine. Previewhost assigns local URLs, starts services in dependency order, and separates each environment’s ports and managed data. Use the CLI, or connect your coding agent over MCP.
npm install -g previewhostOpen sourceRuns on your machine
Services · Serving
| Service | Runtime | Status | Connection | Actions |
|---|---|---|---|---|
| frontend | Next.js | Ready | inventory--frontend.localhost:49837 | |
| api | FastAPI | Ready | inventory--api.localhost:49837 | |
| database | PostgreSQL | Ready | Managed · this environment | |
| cache | Redis | Ready | Managed · this environment |
Setup jobs
migrateSucceededInteractive demo · simulated data
One preview.yaml connects your frontend, API, setup jobs, and databases. Previewhost starts each service after its dependencies are ready.
api:
type: command
cwd: ./api
command: [python, -m, uvicorn, app:app,
--host, 127.0.0.1, --port, "{port}"]
readyPath: /health
dependsOn: [migrate]
env:
DATABASE_URL: {service: database}
REDIS_URL: {service: cache}The API starts after its migration and databases are ready.
Services and setup jobsRun environments for different worktrees, each with separate ports, local URLs, and managed database data.
Worktree isolationPoint the frontend and APIs at their existing source directories. Combine them in one environment, even when their branch names differ.
Multi-repository exampleRead frontend, API, and setup-job output in one view. Filter by source or attempt, then refresh for new output.
Service and job logsLogs capture command and job output. Database container logs are not collected. Browser-console messages appear only when your framework forwards them to a captured process.
Configuration and private setup
Bind environment variables to services, selected host inputs, or stored secret references.
Your agent declares the secret references and services that need them.
You approve access and enter missing values in a private form, outside your agent chat.
Services receive approved values at startup. Stored-secret bindings stay as references in saved configuration.
Application code can still expose values. Log redaction is best effort.
api:
type: command
cwd: ./api
command: [python, -m, uvicorn, app:app,
--host, 127.0.0.1, --port, "{port}"]
env:
DATABASE_URL: {service: database}
REDIS_URL: {service: cache}
API_TOKEN: {secret: "inventory/dev/api-token"}
REGION: {fromEnv: REGION}servicesecretfromEnv--env at startup.For browser requests, {browserUrl: api} supplies an HTTP alias without a startup dependency.
Install your app’s dependencies before startup. Managed databases require local Docker and downloaded images. Non-HTTP background workers are not supported.
CLI and coding agents
Node.js 22.23 or later.
macOS, Linux, and Windows.
Installation requirements
npm install -g previewhostRun it from your terminal, or connect your coding agent through MCP.
Install your app’s dependencies and create preview.yaml with its start commands and connections.
For managed databases or stored secrets, first complete private setup:
previewhost secrets setup --allow-execInspect the configuration, then start:
previewhost inspect
previewhost start --allow-execOpen the returned URL. In another terminal, inspect your environments:
previewhost dashboardKeep the dashboard terminal open while using it.