Raw Twitch in. Typed Twitch out.
velho is one dependency for four Twitch surfaces — OAuth, Helix, chat, and EventSub. It parses each wire format into typed values and validates them with Zod at the boundary.
Then run bunx velho-setup to walk the OAuth flow and write the credentials into your .env file.
import { TwitchChatClient } from "velho";
const chat = new TwitchChatClient({
username: "velhobot",
token: `oauth:${accessToken}`,
autoJoin: ["#velho"],
reconnect: true,
});
// Twitch sends this:
// @badges=subscriber/12;color=#1E90FF;display-name=kettu
// :kettu!kettu@kettu.tmi.twitch.tv PRIVMSG #velho :!ping
chat.on("message", (message) => {
message.channel; // "#velho"
message.username; // "kettu"
message.text; // "!ping"
});
await chat.connect();Modules
Auth
App access, authorization code, and refresh flows. Tokens are cached and renewed before they expire.
TwitchAuth
Helix
Typed GET and POST against any Helix path. Pass a Zod schema to shape the response and read rate limits off every call.
HelixClient
Chat
Join channels, listen, and say things back. PING is answered and dropped sockets reconnect on their own.
TwitchChatClient
EventSub
Verify webhook signatures in constant time and answer the challenge, or hold a WebSocket session open.
handleEventSubWebhook, EventSubWebSocketClient
velho is Finnish for wizard. MIT licensed, built by Joni Juntto. See also Visp, stream tooling for Twitch creators.