{"id":17604576,"url":"https://github.com/6d7a/quito","last_synced_at":"2025-10-27T01:09:20.265Z","repository":{"id":55139894,"uuid":"522904284","full_name":"6d7a/quito","owner":"6d7a","description":"TCP-capable MQTT client for react native","archived":false,"fork":false,"pushed_at":"2023-02-24T15:12:07.000Z","size":1142,"stargazers_count":13,"open_issues_count":4,"forks_count":8,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-11T17:14:15.014Z","etag":null,"topics":["android","ios","mqtt","mqtt-client","react-native","tcp","websocket"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/6d7a.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-09T10:35:08.000Z","updated_at":"2025-01-06T21:42:27.000Z","dependencies_parsed_at":"2024-10-23T06:07:44.124Z","dependency_job_id":null,"html_url":"https://github.com/6d7a/quito","commit_stats":{"total_commits":114,"total_committers":2,"mean_commits":57.0,"dds":0.3157894736842105,"last_synced_commit":"83c529910a94dcf3b8ff1b96a719df3beb4f7647"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/6d7a%2Fquito","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/6d7a%2Fquito/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/6d7a%2Fquito/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/6d7a%2Fquito/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/6d7a","download_url":"https://codeload.github.com/6d7a/quito/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251683355,"owners_count":21626953,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","ios","mqtt","mqtt-client","react-native","tcp","websocket"],"created_at":"2024-10-22T14:10:01.667Z","updated_at":"2025-10-27T01:09:20.201Z","avatar_url":"https://github.com/6d7a.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Quito ![Logo](./docs/assets/quito_round.svg)\r\n\r\nA TCP-capable MQTT client for React Native. The module provides a Typescript API for native MQTT clients on iOS and Android.\r\n\r\n- on Android, quito relies on [Paho](https://www.eclipse.org/paho/index.php?page=clients/java/index.php)\r\n- on iOS, quito uses [CocoaMQTT](https://github.com/emqx/CocoaMQTT)\r\n\r\nThe module provides both promise- and callback-based methods to interact with the native clients.\r\n\r\nThis libraries owes a lot to [davesters](https://github.com/davesters)' and [SudoPlz](https://github.com/SudoPlz)' respective libraries, so thank you :100:\r\n\r\n## Installation\r\n\r\n```sh\r\nnpm install quito\r\n```\r\n\r\nTo make an unencrypted connection to an MQTT broker, make sure a consuming android application allows cleartext traffic, either generally by setting the _android:usesCleartextTraffic_ flag in the application field of the AndroidManifest.xml, or by adding a [security configuration](https://developer.android.com/training/articles/security-config).\r\n\r\n## Usage\r\n\r\nThe module provides promise- and callback-based methods to interact with the native clients.\r\n\r\n#### Callback-based usage\r\n\r\n```typescript\r\nimport { Quito, QuitoOptionsBuilder } from 'quito';\r\n\r\n// build a config using the QuitoOptionsBuilder\r\nconst config = new QuitoOptionsBuilder()\r\n  .uri('tcp://test.mosquitto.org:1883')\r\n  .clientId('quito-test-client')\r\n  .build();\r\n\r\nconst MqttClient = new Quito(config);\r\n\r\nMqttClient.init() // call init() to create native client and set up native event listeners\r\n  .then(() =\u003e {\r\n    // Subscribing to event callbacks\r\n    MqttClient.on(QuitoEvent.CONNECTING, () =\u003e {\r\n      // called when client is connecting\r\n    });\r\n    MqttClient.on(QuitoEvent.CONNECTED, () =\u003e {\r\n      // called when client is connected\r\n    });\r\n    MqttClient.on(QuitoEvent.SUBSCRIBED, (topic: string) =\u003e {\r\n      // called when client has subscribed to a topic\r\n    });\r\n    MqttClient.on(QuitoEvent.UNSUBSCRIBED, (topic: string) =\u003e {\r\n      // called when client has unsubscribed from a topic\r\n    });\r\n    MqttClient.on(\r\n      QuitoEvent.MESSAGE_RECEIVED,\r\n      (topic: string, payload: Uint8Array) =\u003e {\r\n        // called when client has received a message\r\n      }\r\n    );\r\n    MqttClient.on(\r\n      QuitoEvent.MESSAGE_PUBLISHED,\r\n      (topic: string, payload: Uint8Array) =\u003e {\r\n        // called when client has sent a message\r\n      }\r\n    );\r\n    MqttClient.on(QuitoEvent.DISCONNECTED, () =\u003e {\r\n      // called when client has disconnected\r\n    });\r\n    MqttClient.on(QuitoEvent.CONNECTION_LOST, (error?: Error) =\u003e {\r\n      // called when client has unexpectedly lost its connection to the broker\r\n    });\r\n    MqttClient.on(QuitoEvent.EXCEPTION, (error: Error) =\u003e {\r\n      // called when client encountered an error\r\n    });\r\n    MqttClient.on(QuitoEvent.CLOSED, (error?: Error) =\u003e {\r\n      // called when client was closed\r\n    });\r\n\r\n    // connecting to the MQTT broker\r\n    MqttClient.connect();\r\n\r\n    // subscribing to a message topic\r\n    // both a single topic or an array of topics are supported\r\n    MqttClient.subscribe([\r\n      {\r\n        topic: 'first/topic',\r\n        qos: 2, // Quality of Service\r\n      },\r\n      {\r\n        topic: 'second/topic',\r\n        qos: 1,\r\n      },\r\n    ]);\r\n\r\n    // unsubscribing from a message topic\r\n    // both a single topic string or an array of topic strings are supported\r\n    MqttClient.unsubscribe('first/topic');\r\n\r\n    // publishing a message\r\n    MqttClient.publish(\r\n      'first/topic',\r\n      Buffer.from('This is a test message!'),\r\n      0, // Quality of service\r\n      false // whether the message should be retained\r\n    );\r\n\r\n    // checking client connection\r\n    MqttClient.isConnected().then((isConnected: Boolean) =\u003e {\r\n      // process connection state\r\n    });\r\n\r\n    // shutting down client\r\n    MqttClient.end();\r\n  });\r\n```\r\n\r\n#### Promise-based usage\r\n\r\n```typescript\r\nimport { Quito, QuitoOptionsBuilder } from 'quito';\r\n\r\n// build a config using the QuitoOptionsBuilder\r\nconst config = new QuitoOptionsBuilder()\r\n  .uri('tcp://test.mosquitto.org:1883')\r\n  .clientId('quito-test-client')\r\n  .build();\r\n\r\nconst MqttClient = new Quito(config);\r\n\r\nawait MqttClient.init(); // call init() to create native client and set up native event listeners\r\n\r\n// Most message callbacks are redundant\r\n// when using the Promise-based API\r\nMqttClient.on(\r\n  QuitoEvent.MESSAGE_RECEIVED,\r\n  (topic: string, payload: Uint8Array) =\u003e {\r\n    // called when client has received a message\r\n  }\r\n);\r\nMqttClient.on(QuitoEvent.CONNECTION_LOST, (error?: Error) =\u003e {\r\n  // called when client has unexpectedly lost its connection to the broker\r\n});\r\nMqttClient.on(QuitoEvent.EXCEPTION, (error: Error) =\u003e {\r\n  // called when client encountered an error\r\n});\r\n\r\n// connecting to the MQTT broker\r\ntry {\r\n  await MqttClient.connectAsync();\r\n} catch (e: any) {\r\n  // handle error\r\n}\r\n\r\n// subscribing to a message topic\r\n// both a single topic or an array of topics are supported\r\ntry {\r\n  await MqttClient.subscribeAsync([\r\n    {\r\n      topic: 'first/topic',\r\n      qos: 2, // Quality of Service\r\n    },\r\n    {\r\n      topic: 'second/topic',\r\n      qos: 1,\r\n    },\r\n  ]);\r\n} catch (e: any) {\r\n  // handle error\r\n}\r\n\r\n// unsubscribing from a message topic\r\n// both a single topic string or an array of topic strings are supported\r\ntry {\r\n  await MqttClient.unsubscribeAsync('first/topic');\r\n} catch (e: any) {\r\n  // handle error\r\n}\r\n\r\n// publishing a message\r\ntry {\r\n  await MqttClient.publishAsync(\r\n    'first/topic',\r\n    Buffer.from('This is a test message!'),\r\n    0, // Quality of service\r\n    false // whether the message should be retained\r\n  );\r\n} catch (e: any) {\r\n  // handle error\r\n}\r\n\r\n// checking client connection\r\nconst isConnected = await MqttClient.isConnected();\r\n\r\n// shutting down client\r\ntry {\r\n  await MqttClient.endAsync();\r\n} catch (e: any) {\r\n  // handle error\r\n}\r\n```\r\n\r\n### Quito Options\r\n\r\nUse the QuitoOptionsBuilder to generate a config for the Quito MQTT client. The following options for configuring the Quito MQTT client are available:\r\n\r\n- `clientId`: _string_ - Identifier used in the communication with the MQTT bromker\r\n- `username`: _string_ - Username used to authenticate the client against the broker\r\n- `password`: _string_ - Password used to authenticate the client against the broker\r\n- `keepaliveSec`: _number_ - Maximum time interval in seconds between control packets\r\n- `connectTimeoutMs`: _number_ - Maximum time interval the client will wait for the network connection to the MQTT broker to be established\r\n- `will`: _Will_ - MQTT message that the broker will send, should the client connect ungracefully.\r\n  - `topic`: _string_ - Topic the will will be published to\r\n  - `payload`: _string_ - Message of the will Base64-encoded\r\n  - `qos`: _QoS_ - quality of service of the will\r\n  - `retain`: _boolean_ - Indicates whether the will should be retained\r\n- `tls`: _boolean_ - Whether the client will secure the connection to the broker using TLS. Depending on the host platform, the options vary.\r\n  - **On Android**: If `tls == true`, at least the broker's CA certificate `android_caBase64` is required. If the broker expects the client to present a certificate as well, the shared `android_caBase64` plus `android_certificateBase64`, `keyStoreKey`, and `keyStorePassword` options become mandatory\r\n  - **On iOS**: If `tls == true` and no `ios_certKeyP12Base64` is provided, broker certificates will not be validated. If `tls == true` and `ios_certKeyP12Base64` is provided, the client wil authenticate using the contained crypto.\r\n- `ios_certKeyP12Base64`: _String_ - Base64-encoded PKCS12 archive containing client certificate and key\r\n- `android_caBase64`: _String_ - Base64-encoded CA certificate (DER) used by the MQTT broker\r\n- `android_certificateBase64`: _String_ - Base64-encoded self-signed X509 certificate (DER) of the client\r\n- `android_privateKeyBase64`: _string_ - Base64-encoded RSA private key of the client\r\n- `keyStorePassword`: _string_ - Password used in creating the client's keystore\r\n- `cleanSession`: _boolean_ - When set to `true`, the broker will open a non-persistent connection, during which it will not store any subscription information or undelivered messages for the client\r\n- `protocol`: _Protocol_ - Identifies the protocol used in the connection to the broker\r\n- `protocolVersion`: _number_ - Identies the MQTT version used in the connection to the broker\r\n- `reconnectPeriod`: _number_ - Time interval to elapse before a client will attempt to reconnect an unexpectedly disconnected client\r\n- `host`: _string_ - Host name of the MQTT broker to connect to\r\n- `port`: _number_ - Port number of the MQTT broker to connect to","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F6d7a%2Fquito","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F6d7a%2Fquito","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F6d7a%2Fquito/lists"}