a lightweight library for building reactive with discord.js & bun (or node)
[!CAUTION]
dsx is still in early development and experimental. expect breaking changes and evolving apis.
import { Message, Embed, Title, Description, Actions, Button } from 'dsxjs/components';
import { mount } from 'dsxjs/renderer';
import { useSignal, useEffect } from 'dsxjs/hooks';
import { ButtonStyle, Client } from 'discord.js';
import { bot } from './bot';
const Component = () => {
const count = useSignal(0);
return (
<Message>
<Embed>
<Title>Counter</Title>
<Description>{count.value}</Description>
</Embed>
<Actions>
<Button onClick={() => count.value++}>+</Button>
<Button onClick={() => count.value--}>-</Button>
<Button onClick={() => count.value = 0} style={ButtonStyle.Danger}>Reset</Button>
</Actions>
</Message>
)
}
await mount(
Component,
bot,
opts => message.channel.send(opts)
)
useSignal
and useEffect
hooksdsx
makes building interactive discord messages a breeze, combining the declarative UI approach of JSX with a reactive state model inspired by solid.js & react. It allows you to build complex UIs with minimal code, while still being lightweight and performant. instead of manually managing message content, components, and interactions, you write ui components that update themselves automatically.
bun i dsxjs
# or:
npm install dsxjs
pnpm install dsxjs
yarn add dsxjs
or if you want a bot and dsx included (coming soon):
bun create dsxjs
# or:
npm create dsxjs
pnpm create dsxjs
yarn create dsxjs
contributions, bug reports, and feature requests are welcome! See the roadmap and contributing guide for details.
find us on:
dsx
is licensed under the MIT license.
tldr: you're free to use and modify
dsx
, but please keep the license intact and give credit where it's due.