Skip to content

Local development

discord0 dev runs your app on your machine, whichever adapter the project uses.

Terminal window
npx discord0 dev

It:

  • Serves the app at http://127.0.0.1:3000/interactions. Set PORT to use another port.
  • Loads .env and .env.local from the project directory.
  • Reloads when you save a file.
  • Registers your commands with your test server when it starts, and again whenever the command definitions change.

The entry point is src/index.ts, or entry in discord0.config.ts. Pass a path to use another one: npx discord0 dev src/other.ts.

dev syncs commands to guild in discord0.config.ts, which the starter sets from DISCORD_GUILD_ID. Sync replaces every command registered with that server, so the server always matches your code.

  • --guild <id> syncs to another server for this run.
  • --no-sync skips syncing.
  • --tunnel starts a Cloudflare Quick Tunnel, described in the next section.
  • sync: { dev: false } in the config turns it off for good.

If no server ID is set, dev prints a reminder and serves without syncing.

Discord sends interactions only to public HTTPS URLs, so a local server needs a tunnel. Pass --tunnel to start a Cloudflare Quick Tunnel alongside the server. Quick Tunnels don’t need a Cloudflare account.

Terminal window
npx discord0 dev --tunnel

It prints an https://…/interactions URL. Set that as Interactions Endpoint URL on your application’s General Information page in the Developer Portal. The tunnel keeps its URL across hot reloads. Without the flag, dev prints a one-line tip about --tunnel.

dev runs cloudflared through bun x cloudflared. If the tunnel fails or doesn’t connect within 30 seconds, dev keeps serving locally and prints install instructions. You can also start a tunnel yourself in another terminal:

Terminal window
# Cloudflare Quick Tunnel
cloudflared tunnel --url http://127.0.0.1:3000
# ngrok
ngrok http 3000

Quick tunnels get a new URL each time they start, so update the endpoint after restarting the tunnel. An application has one endpoint at a time. If you also have a deployed copy, create a separate development application with its own .env.

dev always runs on Bun as a long-lived process, so no host limit cuts off deferred replies. A handler that works locally can still hit your host’s limit in production. Check Deferred work for your adapter.