API Reference@djs-commands/jsx
Overview
JSX runtime + Components V2 component set for Discord.js bots.
@djs-commands/jsx is an opt-in JSX runtime that compiles JSX trees into discord.js component builders for Components V2. Output is identical to the function-form API in @djs-commands/core — mix the two freely.
bun add @djs-commands/jsx{
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "@djs-commands/jsx"
}
}No Babel, no SWC, no React. The TypeScript compiler (and Bun's transpiler) emits import { jsx } from "@djs-commands/jsx/jsx-runtime" automatically.
import { Container, Section, TextDisplay, Button, render } from "@djs-commands/jsx";
import { MessageFlags } from "discord.js";
await interaction.reply({
flags: MessageFlags.IsComponentsV2,
components: render(
<Container accentColor={0x5865f2}>
<TextDisplay># Welcome</TextDisplay>
<Section accessory={<Button style="primary" customId="ok" label="OK" />}>
Click the button to continue.
</Section>
</Container>
),
});Symbols by topic
render / renderModal
Compile JSX trees to discord.js builders, plus the Fragment helper.
Display components
Container, Section, TextDisplay, MediaGallery, Separator, File, Thumbnail.
Form components
ActionRow, Button, Modal, TextInput, RadioGroup, CheckboxGroup.
Last updated on
