{"id":15476200,"url":"https://github.com/lesnitsky/react-native-webview-messaging","last_synced_at":"2025-04-09T12:05:22.988Z","repository":{"id":21482393,"uuid":"93048120","full_name":"lesnitsky/react-native-webview-messaging","owner":"lesnitsky","description":"✉️ Send/Receive data between React Native app and WebView","archived":false,"fork":false,"pushed_at":"2022-12-08T17:16:36.000Z","size":1788,"stargazers_count":265,"open_issues_count":37,"forks_count":32,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-04-13T23:54:16.345Z","etag":null,"topics":["communication","event","messaging-api","react-native","webview"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/lesnitsky.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-01T11:00:03.000Z","updated_at":"2024-01-10T09:29:57.000Z","dependencies_parsed_at":"2023-01-13T21:30:26.815Z","dependency_job_id":null,"html_url":"https://github.com/lesnitsky/react-native-webview-messaging","commit_stats":null,"previous_names":["r1zzu/react-native-webview-messaging"],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lesnitsky%2Freact-native-webview-messaging","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lesnitsky%2Freact-native-webview-messaging/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lesnitsky%2Freact-native-webview-messaging/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lesnitsky%2Freact-native-webview-messaging/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lesnitsky","download_url":"https://codeload.github.com/lesnitsky/react-native-webview-messaging/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248036063,"owners_count":21037092,"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":["communication","event","messaging-api","react-native","webview"],"created_at":"2024-10-02T03:23:41.509Z","updated_at":"2025-04-09T12:05:22.960Z","avatar_url":"https://github.com/lesnitsky.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# React Native WebView Messaging\n\nReact Native WebView extension with 2-way event-based communication API\n\n[![GitHub stars](https://img.shields.io/github/stars/lesnitsky/react-native-webview-messaging.svg?style=social)](https://github.com/lesnitsky/react-native-webview-messaging)\n[![Twitter Follow](https://img.shields.io/twitter/follow/lesnitsky_dev.svg?label=Follow%20me\u0026style=social)](https://twitter.com/lesnitsky_dev)\n\n:warning: this is v2 branch which is not yet stable. Check out [v1 branch](https://github.com/R1ZZU/react-native-webview-messaging/tree/v1) for v1 docs\n\n## Installation\n\n```sh\nnpm install react-native-webview-messaging@next\n```\n\n## Examples\n\n[Examples](https://github.com/R1ZZU/react-native-webview-messaging/tree/master/examples)\n\n## Usage\n\n### React Native\n\n```javascript\nimport React, { Component } from 'react';\nimport { View, TouchableHighlight } from 'react-native';\nimport { connectToRemote, WebView } from 'react-native-webview-messaging';\n\nexport class ExampleView extends Component {\n  render() {\n    return (\n      \u003cView\u003e\n        \u003cWebView\n          ref={ webview =\u003e { this.webview = webview; }}\n          source={ require('./some-page.html') }\n        /\u003e\n        \u003cTouchableHighlight onPress={this.sendMessageToWebView} underlayColor='transparent'\u003e\n          \u003cText\u003eSend message to WebView\u003c/Text\u003e\n        \u003c/TouchableHighlight\u003e\n      \u003c/View\u003e\n    )\n  }\n\n  async componentDidMount() {\n    this.remote = await connectToRemote(this.webview);\n\n    this.remote.on('text', text =\u003e console.log(text));\n    this.remote.on('json', json =\u003e console.log(json));\n    this.remote.on('custom-event-from-webview', eventData =\u003e console.log(eventData));\n  }\n\n  sendMessageToWebView = () =\u003e {\n    this.remote.sendJSON({\n      payload: 'JSON from RN'\n    });\n\n    this.remote.send('plain text from RN');\n\n    this.remote.emit('custom-event-from-rn', { payload: 'Custom event from RN' });\n  }\n}\n```\n\n### Web\n\n```javascript\nimport { connectToRemote } from 'react-native-webview-messaging/web';\n\nconnectToRemote()\n  .then(remote =\u003e {\n    remote.on('text', text =\u003e console.log(text));\n    remote.on('json', json =\u003e console.log(json));\n    remote.on('custom-event-from-rn', data =\u003e console.log(data));\n\n    remote.send('plain text from WebView');\n    remote.sendJSON({\n      payload: 'JSON from WebView'\n    });\n\n    remote.emit('custom-event-from-webview', { payload: 'Custom event from WebView' });\n  });\n```\n\n## LICENSE\n\nMIT\n\n\n[![GitHub stars](https://img.shields.io/github/stars/lesnitsky/react-native-webview-messaging.svg?style=social)](https://github.com/lesnitsky/react-native-webview-messaging)\n[![Twitter Follow](https://img.shields.io/twitter/follow/lesnitsky_dev.svg?label=Follow%20me\u0026style=social)](https://twitter.com/lesnitsky_dev)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flesnitsky%2Freact-native-webview-messaging","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flesnitsky%2Freact-native-webview-messaging","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flesnitsky%2Freact-native-webview-messaging/lists"}