Docs / Configuration
v1.0.2Latest / April 2026

Project Scripts

Configure Gun with package scripts and CLI flags.

Package scripts

Put the commands your team runs in package.json:

{
  "scripts": {
    "gun:check": "gun check src/index.ts",
    "gun:build": "gun transpile src/index.ts -o build/gun --source-maps",
    "gun:watch": "gun watch src/index.ts -o build/gun"
  }
}

Scripts make the build contract visible in code review.

Entrypoints

Pass the entrypoint directly:

gun check src/server.ts
gun transpile src/server.ts -o build/gun

For multiple deployables, create one script per entrypoint:

{
  "scripts": {
    "gun:build:api": "gun transpile src/api.ts -o build/api",
    "gun:build:worker": "gun transpile src/worker.ts -o build/worker"
  }
}

Output paths

Use a directory that can be deleted safely:

rm -rf build/gun
gun transpile src/index.ts -o build/gun

Keep source files and output files separate.

Environment

Read runtime settings from environment variables:

const port = Number(process.env.PORT ?? 8080)
const databaseUrl = process.env.DATABASE_URL

Validate required values during startup so broken deploys fail before accepting traffic.