DJS Commandsv2 docs
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
tsconfig.json
{
	"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

Last updated on

On this page