Discord Interactions SDK
A lightweight TypeScript/JavaScript library for building Discord webhook applications with built-in signature verification and rich type support.
Quick Start
Get up and running with Discord Interactions in minutes
Install the package
Add discord-interactions to your project using your preferred package manager:npm install discord-interactions
Set up signature verification
Import the verification middleware and configure it with your Discord application’s public key:const express = require('express');
const { verifyKeyMiddleware, InteractionType, InteractionResponseType } =
require('discord-interactions');
const app = express();
const CLIENT_PUBLIC_KEY = process.env.CLIENT_PUBLIC_KEY;
You can find your public key in the Discord Developer Portal under your application’s “General Information” section.
Handle interaction requests
Create an endpoint to receive and respond to Discord interactions:app.post('/interactions',
verifyKeyMiddleware(CLIENT_PUBLIC_KEY),
(req, res) => {
const interaction = req.body;
if (interaction.type === InteractionType.APPLICATION_COMMAND) {
res.send({
type: InteractionResponseType.CHANNEL_MESSAGE_WITH_SOURCE,
data: {
content: 'Hello from Discord Interactions!'
}
});
}
}
);
app.listen(3000);
Configure your Discord application
Set your Interactions Endpoint URL in the Discord Developer Portal to point to your deployed endpoint (e.g., https://yourdomain.com/interactions).Discord will send a PING request to verify your endpoint. The middleware automatically handles PING responses.
Explore by Topic
Deep dive into specific features and capabilities
Interactions
Handle slash commands, message components, and modals with type-safe interfaces
Webhook Events
Receive real-time notifications about activities in your Discord server
Message Components
Build interactive messages with buttons, select menus, and text inputs
Express Integration
Integrate seamlessly with Express and other connect-compatible frameworks
Key Features
Everything you need to build production-ready Discord applications
Ed25519 Signature Verification
Built-in cryptographic verification ensures all requests are authentically from Discord using the Ed25519 algorithm.
TypeScript Types
Comprehensive type definitions for interactions, webhook events, and message components provide full autocomplete and type safety.
Express Middleware
Drop-in middleware for Express and connect-compatible frameworks simplifies integration with existing Node.js applications.
Multi-Runtime Support
Works in Node.js, browsers, and edge runtimes like Cloudflare Workers with Web Crypto API compatibility.
Ready to build on Discord?
Follow our quickstart guide to create your first Discord interaction webhook in minutes.
Get Started Now