Getting Started
Install Shardwire, boot the bot bridge, connect an app process, and verify the first end-to-end event flow.
Shardwire’s first successful setup is intentionally small:
- Start a bot bridge.
- Connect an app bridge.
- Subscribe to a typed event.
- Check that the negotiated capability surface matches what you expect.
Prerequisites
- Node.js
>=18.18for the package runtime. - A Discord bot token in
DISCORD_TOKEN. - A shared secret in
SHARDWIRE_SECRET. - A local loopback URL such as
ws://127.0.0.1:3001/shardwire.
ws://is for loopback only. Usewss://for remote deployments.
Install
npm install shardwireBot process
import { createBotBridge } from 'shardwire';
const bridge = createBotBridge({
token: process.env.DISCORD_TOKEN!,
intents: ['Guilds', 'GuildMessages', 'GuildMembers', 'MessageContent'],
server: {
port: 3001,
secrets: [process.env.SHARDWIRE_SECRET!],
},
});
await bridge.ready();
console.log('bot bridge ready');App process
import { connectBotBridge } from 'shardwire';
const app = connectBotBridge({
url: 'ws://127.0.0.1:3001/shardwire',
secret: process.env.SHARDWIRE_SECRET!,
appName: 'dashboard',
});
app.on('messageCreate', ({ message }) => {
console.log('message', message.channelId, message.content);
});
await app.ready();
console.log(app.capabilities());What to verify immediately
bridge.ready()completes without secret or transport validation errors.app.ready()authenticates and returns negotiated capabilities.- The event you subscribed to appears in
app.capabilities().events. - Your bot intents cover the events you expect to produce.
Where to go next
- Read Bridge Architecture for the runtime split.
- Read Capabilities & Scoped Secrets before adding more app consumers.
- Read Diagnostics before you deploy.