Local development
discord0 dev runs your app on your machine, whichever adapter the project
uses.
npx discord0 devIt:
- Serves the app at
http://127.0.0.1:3000/interactions. SetPORTto use another port. - Loads
.envand.env.localfrom 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.
Command sync
Section titled “Command sync”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-syncskips syncing.--tunnelstarts 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.
HTTPS tunnel
Section titled “HTTPS tunnel”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.
npx discord0 dev --tunnelIt 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:
# Cloudflare Quick Tunnelcloudflared tunnel --url http://127.0.0.1:3000
# ngrokngrok http 3000Quick 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.
Deferred work while developing
Section titled “Deferred work while developing”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.