tmi.js is a JavaScript client library for the Twitch Messaging Interface, usable from Node.js and directly in the browser, and built for developers who write Twitch chat bots and chat-driven interfaces.
What it is
tmi.js is a JavaScript library that speaks to the Twitch Messaging Interface, published on npm as tmi.js and importable from Node.js or available in the browser. It exposes a single entry point, tmi.Client, constructed with connection options, an identity (a bot username plus an OAuth token) and the list of channels the client should join. From that point the Twitch chat stream arrives as ordinary events, so a bot is written as a set of listeners rather than as a hand-rolled connection and parsing routine.
The concrete problem it solves is boilerplate. Every Twitch chat bot has to authenticate, hold a connection, join channels, read incoming payloads and send replies, and without a library each project repeats that work. tmi.js replaces that per-project integration code with one configured client and a documented event surface, shown in the README as client.on('message', (channel, tags, message, self) => {...}) for reading chat and client.say(channel, ...) for replying. It lives in the Node.js and browser JavaScript ecosystem, filed under AI & Machine Learning / AI Interaction & Interfaces.
Key capabilities
- tmi.Client constructor taking options (including options.debug), an identity with username and an oauth: password, and a channels array.
- Event-driven chat handling through client.on('message', ...), which supplies the channel name, tags metadata, the raw message and the self flag.
- Message sending through client.say(channel, message), used in the README example to answer the !hello command.
- Connection lifecycle through client.connect(), which returns a promise handled with .catch(console.error).
- Browser build exposed globally as tmi on window, so front-end code can construct new tmi.Client(...) without a bundler.
- Prebuilt browser releases on the release page, or a local build through git clone, npm install and npm run build.
- TypeScript support through the separate @types/tmi.js package, installed with npm i -D @types/tmi.js.
Who uses it and how
- Node.js bot authors who need a process joined to one or more channels, configured with a bot account and OAuth token.
- Front-end developers who load the browser build and use the global tmi object for chat-driven pages.
- TypeScript teams that add @types/tmi.js as a development dependency to type chat events.
- Chatbot and chat-interface projects, matching the repository topics chat, chatbot, nodejs and twitchdev.
- Contributors following CONTRIBUTING.md, with help discussion in the Twitch API Discord server and the official TwitchDev Discord server.
Getting started
Install with npm i tmi.js for Node, or use the browser build exposed as tmi on window. Prebuilt browser releases are published on the release page, and a local build runs git clone, npm install and npm run build.
How it compares
No list of paid products that tmi.js replaces is provided in the facts, and no directly comparable library is named there either, so it stands alone in this registry. Its positioning comes from the facts themselves: MIT licensed, JavaScript, aimed at the Twitch Messaging Interface, with documentation hosted at tmijs.com.
When to use it โ and when not to
It suits projects that need Twitch chat in JavaScript or Node and are prepared to own the bot process, its credentials and its OAuth token, since the facts describe a library and not a hosted service. Documentation is not kept in the README but in the separate tmijs/docs repository, so anyone evaluating it should read that alongside the README, which is example-driven and thin on reference material. Type definitions ship separately as @types/tmi.js rather than with the library, and the repository carries 34 open issues.
project readme (upstream, from github) โ read inline
tmi.js


Website |
Documentation currently at tmijs/docs |
Changelog on the release page
Install
Node
$ npm i tmi.js
const tmi = require('tmi.js');
const client = new tmi.Client({
options: { debug: true },
identity: {
username: 'bot_name',
password: 'oauth:my_bot_token'
},
channels: [ 'my_channel' ]
});
client.connect().catch(console.error);
client.on('message', (channel, tags, message, self) => {
if(self) return;
if(message.toLowerCase() === '!hello') {
client.say(channel, `@${tags.username}, heya!`);
}
});
Browser
Available as "tmi" on window.
<script src="/scripts/tmi.min.js"></script>
<script>
const client = new tmi.Client({ /* ... */ });
client.connect().catch(console.error);
</script>
Prebuilt Browser Releases
Release page
Build Yourself
$ git clone https://github.com/tmijs/tmi.js.git
$ npm install
$ npm run build
Type Definitions
$ npm i -D @types/tmi.js
Community
Contributors
Thanks to all of the tmi.js contributors!
Contributing guidelines
Please review the guidelines for contributing of the tmi.js repository. We reserve the right to refuse a Pull Request if it does not meet the requirements.