Vercel Functions
@discord0/adapter-vercel deploys your app as a Vercel Function with the
Vercel CLI.
npx discord0 init my-bot --adapter vercelWhat deploy generates
Section titled “What deploy generates”.discord0/vercel contains:
api/interactions.mjs,- a
package.jsonthat depends on@vercel/functionsand pins Node.js 22, - a
vercel.jsonthat rewrites/interactionsand each webhook path to the function, and - a
.vercelignorethat keeps source maps out of the upload.
The Vercel CLI asks you to log in and link a project on the first deploy.
Deploys are previews unless you pass --prod:
npx discord0 deploy --prodUse the production domain for your Interactions Endpoint URL. Preview URLs change with each deploy and may be behind Deployment Protection, which would block Discord’s requests.
Credentials
Section titled “Credentials”Add DISCORD_PUBLIC_KEY and DISCORD_BOT_TOKEN in Project Settings →
Environment Variables, or from .discord0/vercel:
cd .discord0/vercelnpx vercel env add DISCORD_PUBLIC_KEY productionnpx vercel env add DISCORD_BOT_TOKEN productionVariables apply to new deployments, so deploy again after adding them.
Deferred work
Section titled “Deferred work”The adapter passes deferred work to
waitUntil() from @vercel/functions.
When you leave autoDeferAfterMs unset, the adapter defaults it to 1000ms.
Cold starts often take 0.7 to 1.6 seconds before the handler runs, and the
lower default still fits the acknowledgement inside Discord’s 3-second
window. Set autoDeferAfterMs on new Discord() to
override. See Deferred work.
- The function’s maximum duration. Promises passed to
waitUntilshare the function’s timeout. Vercel cancels them if the function times out. - With fluid compute, on by default, the default maximum duration is 300 seconds on every plan. Hobby can’t raise it. Pro and Enterprise can raise it to 800 seconds. (Duration limits)
deployrewritesvercel.jsoneach time, so set a longer duration as the project default in Project Settings → Functions rather than in the generated file.
Scheduled tasks
Section titled “Scheduled tasks”Each scheduled task becomes a Cron Job in
vercel.json that calls /api/tasks?task=<name>, served by api/tasks.mjs.
Set CRON_SECRET in the project. Vercel sends it in the Authorization header
of each cron request, and the route refuses requests without it. Cron Jobs run in UTC, on production deployments only. Hobby allows only
schedules that run at most once a day, and runs them anywhere within the
scheduled hour.