Scaffolding and checkups
init writes a verified route; doctor finds what is misconfigured.
init creates a working verified route and wires up its env var, so a new endpoint starts from the correct shape instead of a blank file:
npx next-webhooks init stripe
npx next-webhooks init discordIt writes app/api/webhooks/<provider>/route.ts (or under src/app when that is where your app lives) and appends the provider's env var to .env.local when it is not already set anywhere. Providers with special protocol steps get them scaffolded: the Slack template answers url_verification, the Discord template answers both PING shapes.
It never overwrites without --force, never touches an env var that already has a value, and --dir puts the route somewhere else.
doctor
doctor answers "why is my webhook not working" before the first request is sent:
$ npx next-webhooks doctor
app/api/webhooks/stripe/route.ts (stripe)
ok STRIPE_WEBHOOK_SECRET (.env.local)
app/api/webhooks/github/route.ts (github)
MISSING GITHUB_WEBHOOK_SECRET is not set (checked the environment
and .env, .env.development, .env.local, .env.development.local)
1 problem found.It finds every route file under app or src/app that uses next-webhooks, reports which provider each one uses, and resolves each env var the route reads the same way the route would: real environment first, then the env files. It also warns when .webhooks/ exists but is not gitignored (captures can contain real customer data) and checks the Node version.
doctor exits 1 when a route reads an env var that is set nowhere, so it can gate CI.