NextBot is a Discord bot template built with Next.js that runs entirely on the Edge Runtime, designed for quick deployment on Vercel.
What is NextBot?
NextBot is a GitHub template repository for building Discord bots using Next.js and Discord's Interactions Endpoint. Instead of maintaining a persistent WebSocket connection, it receives and responds to slash-command interactions via an HTTP endpoint. The template includes a working bot with demo commands, and it runs 100% at the edge with no cold starts, making it free to deploy on Vercel's free tier. It is built with TypeScript and uses Next.js Route Handlers in the App Router.
Key Features
- Edge Runtime — The bot runs entirely on Vercel's Edge Runtime, offering faster responses with no cold starts and a more generous free tier than traditional serverless functions like AWS Lambda.
- Free deployment — Deploy to Vercel in seconds at no cost; there is no need to host your own server or VM, so you can skip Heroku or EC2.
- Built-in slash commands — The template ships with four example commands:
/pokemon(usesnext/ogto generate a dynamic image with a Pokemon sprite and Pokedex number),/ping,/invite, and/randompic. - Dynamic image generation — The
/pokemoncommand demonstrates generating an image at runtime withnext/og, with responses cached at the edge. - Extensible with Next.js — Because it is a full web framework, you can add a companion web app (for example, an admin portal in
src/app/page.tsx) alongside your bot. - Easy local development — The README explains how to use ngrok or Cloudflare Tunnel for local testing, with a simple
yarn devcommand and environment variable setup. - Command registration script — A
yarn register-commandsscript is included to register your slash commands with Discord. - Request verification — It includes helper code in
src/discord/verify-incoming-request.tsto verify incoming requests from Discord for security.
Who is it for?
- Discord bot developers who want a minimal, free way to host a bot without managing servers and who are familiar with Next.js.
- Next.js developers who want to learn how to integrate Discord's Interactions Endpoint with the App Router and Route Handlers.
- Hobbyists building small bots who want to quickly get a bot online with slash commands and dynamic images, using the demo commands as a starting point.
What can you do with NextBot?
- Build a custom Discord bot — Add your own slash commands by creating new route handlers and registering them with the included script.
- Generate dynamic images — Use
next/ogto create image responses for commands like/pokemon, which fetches data from PokeAPI and caches the result at the edge. - Pair your bot with a web app — Use Next.js to build an admin panel or landing page at the root route while the bot runs at
/api/interactions.
How does NextBot work?
NextBot uses Discord's Interactions Endpoint (an HTTPS URL) to receive interactions. When a user sends a slash command, Discord sends an HTTP POST to your /api/interactions route. The template verifies the request signature, handles the interaction, and returns a response. Locally, you use a tunnel like ngrok so Discord can reach your machine; in production, you set the endpoint to your Vercel deployment URL.
Alternatives
The Discord documentation provides an official tutorial for hosting a Discord bot on Cloudflare Workers, which NextBot's README points to as the closest comparison. Other approaches include running a traditional Node.js bot with a persistent WebSocket connection on your own server, or using AWS Lambda with serverless functions (though those may have cold starts and higher cost).
FAQ
Is NextBot free?
Yes. The template is free to use and deploy. The project is designed to run on Vercel's free tier, and the README states that you can deploy at no cost without hosting a server or VM.
How do I test NextBot locally?
Run yarn dev to start the Next.js app, then use ngrok or Cloudflare Tunnel to expose port 3000. Set the Discord app's Interactions Endpoint URL to your tunnel's HTTPS URL plus /api/interactions, and set ROOT_URL in your local environment variables file to the same tunnel URL.
What commands are included?
The demo bot includes /pokemon, which returns a dynamically generated image of a Pokemon with its sprite, name, and Pokedex number; /ping for a pong response; /invite to get an invite link; and /randompic for a random picture.
Does NextBot require a server?
No. It runs entirely on the edge using Next.js Route Handlers. In production you deploy it to Vercel or any platform that supports Next.js, and you do not need to maintain your own server or VM.
Can I add my own commands?
Yes. You can add new Route Handlers and modify the command registration script. The README includes instructions for registering global application commands via the Discord API.





