Configuration

Each and every option listed below is optional. Running tmi.js without options will result as an anonymous connection to Twitch and you will have to join the channels manually.

options: (Optional)

  • clientId: String - Used to identify your application to the API (Default: null)
  • debug: Boolean - Show debug messages in console (Default: false)

connection: (Optional)

  • server: String - Connect to this server (Overrides cluster and connect to this server instead)
  • port: Integer - Connect on this port (Default: 80)
  • reconnect: Boolean - Reconnect to Twitch when disconnected from server (Default: false)
  • maxReconnectAttempts: Integer - Max number of reconnection attempts (Default: Infinity)
  • maxReconnectInterval: Integer - Max number of ms to delay a reconnection (Default: 30000)
  • reconnectDecay: Integer - The rate of increase of the reconnect delay (Default: 1.5)
  • reconnectInterval: Integer - Number of ms before attempting to reconnect (Default: 1000)
  • secure: Boolean - Use secure connection (SSL / HTTPS) (Overrides port to 443)
  • timeout: Integer - Number of ms to disconnect if no responses from server (Default: 9999)

identity: (Optional)

  • username: String - Username on Twitch
  • password: String - OAuth password on Twitch

channels: Array - List of channels to join when connected (Default: [])

logger: Object - Custom logger with the methods info, warn, and error

Examples

Node

var tmi = require("tmi.js");

var options = {
    options: {
        debug: true
    },
    connection: {
        reconnect: true
    },
    identity: {
        username: "Schmoopiie",
        password: "oauth:a29b68aede41e25179a66c5978b21437"
    },
    channels: ["#schmoopiie"]
};

var client = new tmi.client(options);

// Connect the client to the server..
client.connect();

Browser

index.html

<!DOCTYPE html>
<html lang="en">
	<head></head>
	<body>
        <!--[IF IE]><!-->
        <script src="https://cdn.polyfill.io/v2/polyfill.min.js"></script>
        <!--<![endif]-->
        <script src="//cdn.tmijs.org/js/latest/1.x/tmi.min.js"></script>
        <script src="example.js"></script>
	</body>
</html>

example.js

var options = {
    options: {
        debug: true
    },
    connection: {
        reconnect: true,
    },
    identity: {
        username: "Schmoopiie",
        password: "oauth:a29b68aede41e25179a66c5978b21437"
    },
    channels: ["#schmoopiie"]
};

var client = new tmi.client(options);

// Connect the client to the server..
client.connect();