Follow these steps to connect Discord, send a Discord message from Next.js, and track delivery.
Discord posting goes through a webhook you create yourself in the channel's settings. There is no bot to install and no OAuth dance: Discord hands you a URL, yeetpost calls it once to read back the webhook's name and channel, and messages land under the name and avatar you gave it. The URL is a credential, so treat it like an API key. From Next.js you call it through the yeetpost npm package, from a route handler, a server action or a scheduled job.
What Discord takes
How you connect
A webhook URL of the form https://discord.com/api/webhooks/<id>/<token>
Connection slug
discord for the first channel, then a slug built from the webhook name
Text limit
2000 characters, counted in code points
Images
Up to 5 per post, png, jpeg, gif or webp, 8 MB each
Click Add connection, select Discord, and paste the URL
The URL has to be a real Discord webhook URL, so https://discord.com/api/webhooks/<id>/<token>. Anyone holding it can post to that channel, so treat it like an API key. To revoke it, delete the webhook in Discord.
Paste your connection slug here and we'll auto-fill it into the code examples below.
Paste your API key here and we'll auto-fill it into the code examples below.
3
Send your post
Install the yeetpost package:
npminstall yeetpost
Set your API key as an environment variable in .env.local. Keep it out of any name that starts with NEXT_PUBLIC_, because those are inlined into the browser bundle:
YEETPOST_API_KEY=<your-api-key>
Send the post from a route handler, a server action or a scheduled job, never from a client component:
View all posts sent via yeetpost, including status and timestamps
5
Review the security checklist
Read the security checklist before you ship: where the key lives, who can trigger a post, and what to log.
When a Discord post is refused
Each of these fails only the Discord item. Every other connection on the same request still goes out. The full vocabulary is in the errors reference.
Code
Status
When
invalid_request
400
Text over 2000 code points
media_unsupported
400
The server refused the image, usually its own upload limit
shape_unsupported
400
A thread or a firstComment was given. Discord has neither
platform_rejected
422
The webhook is gone, is no longer allowed to post, is rate limited past 5 seconds, or Discord refused the message
internal_server_error
500
Our fault. Quote the req_id when you report it
Discord FAQ
Why can I not send a thread to Discord?
A webhook posts messages, it cannot reply to one. Ask for a thread on a Discord connection and that item is refused with shape_unsupported, while the connections that do have threads, X, Bluesky, Telegram and Mastodon, still go out.
Can I post to several Discord channels?
Yes. One webhook per channel and one connection per webhook. Name them all in connectionSlugs and the same call fans out to every channel.
The webhook stopped working. What happened?
Somebody deleted it in Discord, or the channel's permissions changed. Posts come back 403 reconnect_required, because Discord answers a deleted or no longer allowed webhook with a 404, 401 or 403. Create a new webhook and paste the new URL to reconnect.
Does the message show my name?
No. It shows the name and the avatar you gave the webhook when you created it in Discord. Change them there and every later message follows.
Where should this run in a Next.js app?
On the server: a route handler, a server action or a cron job. The API key has to stay there, so read it from process.env and never put it behind a NEXT_PUBLIC name, which would ship it to the browser.