Browse the docs

Serve & Watch

serve starts a TypeScript development server and keeps generated output current while you work.

Entrypoint resolution

The extension resolves the application entrypoint from:

  1. ./serve in package.json exports
  2. --entrypoint <path>
  3. a fast build fallback when no serve export exists
putnami serve .
putnami serve . --port 4000
putnami serve . --entrypoint src/server.ts

putnami serve, the compiled binary and the container image all run src/serve.ts (the ./serve export) and resolve the same conf/ config, putnami.port included. A PORT variable, which an image sets, still outranks putnami.port. putnami serve sets PORT=0 and reaches the service at a stable address derived from its project id, so putnami.port does not place it; see Run your system locally. See What the compiled binary runs.

Options

Option Use
--entrypoint <path> Override the serve entrypoint
--watch <boolean> Enable or disable watch mode
--port <number> With one selected project, place its address on this port for the run
--debug Forward LOG_LEVEL=debug to the application
--inspect, --inspect-wait, --inspect-brk Enable Bun inspector modes

Without the CLI

A project the typescript-server and typescript-web templates create runs with Bun alone, without the Putnami CLI or a putnami.workspace.json. @putnami/application ships the commands its scripts call:

bun dev          # putnami-dev: generate, serve under Bun's watch, generate again on each change
bun test         # createTestApp runs the generate step when an output is missing or stale
bun run build    # putnami-build: the production executable, --image for the container build context

putnami serve reloads the server through Bun's watch. bun dev also pushes edits to the open browser without a reload: see Hot updates in development. The details are in the putnami-dev and putnami-build guides; tests are in Testing.

Multi-service mode

Declare runtime service dependencies in package.json:

{
  "putnami": {
    "runsWith": ["catalogue-api", "profile-api"]
  }
}

Then run:

putnami serve web-app --watch

Putnami starts the web app and its declared services together. If runsWith is absent, serve walks the dependency graph for projects with ./serve exports.

Port conflicts

The serve job checks for port conflicts before starting. Conflicts are resolved interactively, or automatically in CI, and the selected port is saved to project config for future runs.