Twilio Chat client library
=============
Twilio Chat is a service for messages delivery over ip networks.
Visit our official site for more detalis: [https://www.twilio.com/chat](https://www.twilio.com/chat)


Instantiating and using
------------
To use the library you need [to generate a token](https://www.twilio.com/docs/chat/create-tokens) and pass it to the Chat Client constructor.

### NPM
```
npm install --save twilio-chat
```

Using this method, you can `require` `twilio-chat` and then use the client:
```
const { Client } = require('twilio-chat');
const client = new Client(token);
// Before you use the client, subscribe to the `'stateChanged'` event and wait 
// for the `'initialized'` state to be reported.
client.on('stateChanged', (state) => {
  if (state === 'initialized') {
    // Use the client
  }
}
```

The SDK could also be imported using the ES module syntax:
```
import { Client } from 'twilio-chat';
const client = new Client(token);
// Before you use the client, subscribe to the `'stateChanged'` event and wait 
// for the `'initialized'` state to be reported.
client.on('stateChanged', (state) => {
  if (state === 'initialized') {
    // Use the client
  }
}
```

### CDN
Releases of `twilio-chat.js` are hosted on a CDN, and you can include these
directly in your web app using a `<script>` tag.
```html
<script src="https://media.twiliocdn.com/sdk/js/chat/v6.0/twilio-chat.min.js"></script>
```
Using this method, `twilio-chat.js` will set a browser global `Twilio.Chat` through which you can use the client:
```
const client = new Twilio.Chat.Client(token);
```


Changelog
---------
See this [link](https://www.twilio.com/docs/chat/javascript/changelog#change-logs).
