{"id":16242143,"url":"https://github.com/tuanpmt/react-native-mqttjs","last_synced_at":"2025-09-02T12:41:07.463Z","repository":{"id":47255090,"uuid":"59546580","full_name":"tuanpmt/react-native-mqttjs","owner":"tuanpmt","description":"Pure javascript Websocket MQTT client library for react-native","archived":false,"fork":false,"pushed_at":"2021-09-06T15:08:47.000Z","size":7,"stargazers_count":27,"open_issues_count":4,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-03T05:05:29.831Z","etag":null,"topics":["mqtt","react-natve"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tuanpmt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-24T06:31:11.000Z","updated_at":"2023-12-15T09:01:38.000Z","dependencies_parsed_at":"2022-09-13T07:51:46.567Z","dependency_job_id":null,"html_url":"https://github.com/tuanpmt/react-native-mqttjs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tuanpmt/react-native-mqttjs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuanpmt%2Freact-native-mqttjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuanpmt%2Freact-native-mqttjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuanpmt%2Freact-native-mqttjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuanpmt%2Freact-native-mqttjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tuanpmt","download_url":"https://codeload.github.com/tuanpmt/react-native-mqttjs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuanpmt%2Freact-native-mqttjs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273287154,"owners_count":25078567,"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","status":"online","status_checked_at":"2025-09-02T02:00:09.530Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["mqtt","react-natve"],"created_at":"2024-10-10T14:09:40.739Z","updated_at":"2025-09-02T12:41:07.396Z","avatar_url":"https://github.com/tuanpmt.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-native-mqttjs\n\n## Features\n\nThis is 100% Pure javascript Websocket MQTT client library without any dependencies for [react-native](https://facebook.github.io/react-native), use original react-native Websocket, port from: [MQTT client library for Contiki](https://github.com/esar/contiki-mqtt) - Prefer for any IoT Mobile applications using react-native\n\nSupport subscribing, publishing, authentication, will messages, keep alive pings and all 3 QoS levels (it should be a fully functional client).\n\nSampe as [esp_mqtt for ESP8266 chip](https://github.com/tuanpmt/esp_mqtt) and should replace for [react-native-mqtt](https://github.com/tuanpmt/react-native-mqtt)\n\n## Install\n\n`npm i react-native-mqttjs --save`\n\n## Basic usage\n\n```javascript\nimport { MqttClient } from 'react-native-mqttjs';\n\nvar mqtt = new MqttClient();\nmqtt.connect('ws://test.mosquitto.org:8080');\n\nmqtt.subscribe({'/topic1': 0}, () =\u003e {\n  console.log('subscribe success topic1 with qos 0');\n});\nmqtt.subscribe([{'/topic2': 1}, {'/topic3': 2}], () =\u003e {\n  console.log('subscribe success topic2 with qos 1, topic3 with qos 2');\n});\n\nmqtt.publish('/topic1', 'test', {qos: 0, retain: 0}, () =\u003e {\n  console.log('publish success');\n});\n\nmqtt.addListener('message', (topic, data) =\u003e {\n  console.log('data arrived, topic: ' + topic + ' - data: ' + data);\n});\n\nmqtt.addListener('connect', () =\u003e {\n  console.log('mqtt connected');\n});\n\n```\n\n## API\n\n- Options:\n  + keepalive: 120 seconds\n  + reschedulePings: reschedule ping messages after sending packets (default true)\n  + clientId: 'mqttjs_' + Math.random().toString(16).substr(2, 8)\n  + protocolId: 'MQTT' or 'MQIsdp'\n  + clean: true, set to false to receive QoS 1 and 2 messages while offline\n  + reconnectPeriod: 1000 milliseconds, interval between two reconnections\n  + connectTimeout: 30 * 1000 milliseconds, time to wait before a CONNACK is received\n  + username: the username required by your broker, if any\n  + password: the password required by your broker, if any\n  + will: a message that will sent by the broker automatically when the client disconnect badly. The format is:\n    - topic: the topic to publish\n    - payload: the message to publish\n    - qos: the QoS\n    - retain: the retain flag\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftuanpmt%2Freact-native-mqttjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftuanpmt%2Freact-native-mqttjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftuanpmt%2Freact-native-mqttjs/lists"}