@discordkit/client
v4.3.0
Published
A REST API Client for Discord
Maintainers
Readme
A TypeScript SDK for Discord, with support for the REST API and the native Social SDK.
What is Discordkit?
Discordkit is a monorepo of small, focused, tree-shakeable packages. Use them to build Discord apps and integrations in TypeScript. It covers three surfaces:
- The REST/HTTP API. A fully-typed Fetcher and a
valibotschema for every Discord endpoint. Composition helpers add runtime validation, react-query, and tRPC. The OAuth2 utilities assume no framework. - The Gateway. A WebSocket client for real-time events, where each dispatch event is its own import. It runs on Cloudflare Workers, Durable Objects, and Node.
- The native Social SDK. A functional bridge to Discord's Social SDK for desktop runtimes: rich presence, OAuth, relationships, lobbies, messaging, and voice. Adapters run it in an Electron main process or a Tauri sidecar, then expose it to the UI over a typed bridge.
Every package ships ESM, generated .d.ts types, and sideEffects: false. You pay only for what you import.
[!NOTE] Discordkit recently published its first stable releases. The REST surface is complete. The Gateway, the native Social SDK packages, and the examples below are still changing. Expect rough edges, and read each package's own README for current usage.
What it ships
Usage documentation lives in each package's README. This table is the map.
REST / HTTP API
| Package | What it does |
| ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| @discordkit/client | A Fetcher + valibot schema for every Discord REST endpoint. The main entry point for the HTTP API. |
| @discordkit/core | The runtime that powers client: session/token management, the request layer, validation primitives, and the composition helpers toValidated, toQuery, and toProcedure (tRPC). |
| @discordkit/oauth | Framework-agnostic Discord OAuth2 utilities (PKCE authorize, token exchange/refresh) with no framework or storage assumptions. |
Realtime / Gateway
| Package | What it does |
| ------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| @discordkit/gateway | A tree-shakeable Gateway (WebSocket) client for Cloudflare Workers, Durable Objects, and Node. Every dispatch event is its own import, with typed intents. |
Native / Social SDK
| Package | What it does |
| --------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| @discordkit/native | Functional TypeScript bridge to the Discord Social SDK for Electron, Tauri, and headless Node — rich presence, auth, users, relationships, lobbies, messaging, and voice. |
| @discordkit/electron | Electron adapter for native — run the Social SDK in the main process and reach it from the renderer over a typed IPC bridge. |
| @discordkit/tauri | Tauri adapter for native — run the Social SDK in a Node sidecar and reach it from the webview over a typed kkrpc bridge. |
The Social SDK shared library can't be redistributed, so you supply it yourself. See
@discordkit/nativefor how to point the packages at it and which SDK versions are supported.
Examples
Runnable apps in examples/, each wiring one or more packages into a real framework.
| Example | Highlights |
| --------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| with-cloudflare | Gateway Event Inspector — DevTools for the Gateway, on a Worker + Durable Object (gateway). |
| with-electron | Rich Presence live editor (Social SDK via native + electron), modelled on Discord's Developer Portal visualizer. |
| with-tauri | A live, tunable unified friends list built on your real Discord relationships (Social SDK via native + tauri). |
| with-nextjs | Discord OAuth2 login + authenticated API calls in Next.js (App Router). |
| with-nextjs-better-auth | The same, but with Better Auth owning the OAuth2 flow. |
| with-astro | OAuth2 login + authenticated calls in Astro (SSR). |
| with-tanstack-start | OAuth2 login + authenticated calls in TanStack Start. |
| with-waku | OAuth2 login + authenticated calls in Waku. |
Repository layout
packages/ published packages (client, core, oauth, native, electron, tauri)
examples/ runnable example apps, one per framework/runtime
docs/ design notes and architecture specs
static/ logo + brand assetsWorking locally
Discordkit uses Vite+ as its toolchain. The global vp CLI drives Oxlint, Oxfmt, tsdown, and Vitest. Bumpy handles versioning and release.
vp install # install dependencies (run after every pull)
vp check --fix # format + lint + typecheck, with autofixes
vp test # run the Vitest suitesTo run an example, install at the root, then start it from its directory. Each example's README lists its own dev command and the .env values it needs:
vp install
cd examples/with-nextjs
vp devThe native Social SDK packages are unit-tested against a mock FFI backend, so vp test needs no SDK binary. A separate CI job loads the real SDK to verify the ABI. That job needs the non-redistributable binary, so it is maintainer-only and never gates contributions.
Contributing
- Branch off
mainand make your change. - Run
vp check --fixandvp testuntil green. - Add a bump file describing what changed:
yarn bumpy add(or the/bumpy-add-changeskill). This drives the version bump and changelog for your PR. - Open a pull request.
📣 Acknowledgements
Endpoint documentation taken from Discord's Official API docs.
🥂 License
Released under the MIT license © Drake Costa.
