{"id":21899325,"url":"https://github.com/whitedogg13/react-native-html5-loader","last_synced_at":"2026-04-16T03:31:29.992Z","repository":{"id":57337465,"uuid":"142993871","full_name":"whitedogg13/react-native-html5-loader","owner":"whitedogg13","description":"Mini library to help you easily integrate existing web library into React Native","archived":false,"fork":false,"pushed_at":"2018-08-03T05:45:07.000Z","size":11,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-20T21:47:22.605Z","etag":null,"topics":["android","html5","ios","react-native"],"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/whitedogg13.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":"2018-07-31T09:39:17.000Z","updated_at":"2020-12-06T12:53:04.000Z","dependencies_parsed_at":"2022-09-13T02:32:07.438Z","dependency_job_id":null,"html_url":"https://github.com/whitedogg13/react-native-html5-loader","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/whitedogg13/react-native-html5-loader","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whitedogg13%2Freact-native-html5-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whitedogg13%2Freact-native-html5-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whitedogg13%2Freact-native-html5-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whitedogg13%2Freact-native-html5-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/whitedogg13","download_url":"https://codeload.github.com/whitedogg13/react-native-html5-loader/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whitedogg13%2Freact-native-html5-loader/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31870506,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T15:24:51.572Z","status":"online","status_checked_at":"2026-04-16T02:00:06.042Z","response_time":69,"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":["android","html5","ios","react-native"],"created_at":"2024-11-28T14:41:14.324Z","updated_at":"2026-04-16T03:31:29.956Z","avatar_url":"https://github.com/whitedogg13.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-native-html5-loader\n\nMini library to help you easily integrate existing web library into React Native!\n\n## Install\n\nnpm install --save react-native-html5-loader\n\n## What can it do for you?\n\nThis is indeed a mini library, but it offers some good stuff to you:\n\n* Create base HTML template inside Webview, let you easily inject the part you need for customization\n* Hook up basic communication channel between the WebView and React Native using the `postMessage`. The message format is redux like: `type` and `payload`, so you won't need to manually stringify or parse anything youself.\n* Handle WebView initialization to `avoid the possible race condition between WebView and React Native`, since there're running in their own JS runtime\n* You can `write JS function for web directly in your React Native project` (NOTICE: es5 syntax only)\n\n## Example \n\nPlease see `examples` directory, we have provided 3 examples for now:\n\n* A simple `Counter` example\n* An example to integrate `SignaturePad` js library\n* An example to integrate `ThreeJs` to show 3D object\n\n## API Usage\n\nLet's use a simple `Counter` example to explain the usage. \n\nWhat we want to accomplish is:\n\n* Create the counter UI inside `WebView`\n* Increment or decrement the counter value in `React Native` side.\n\nThe full code is here, very short and clean:\n\n```javascript\nimport React, {Component} from 'react';\nimport {View, Text, TouchableOpacity, WebView} from 'react-native';\nimport Html5Loader from 'react-native-html5-loader';\n\nexport default class App extends Component {\n  render() {\n    return (\n      \u003cHtml5Loader\n        head={`\n          \u003cstyle\u003e\n            body { margin:0; padding: 20px; }\n            h1 { font-size: 100px; }\n          \u003c/style\u003e\n        `}\n        body={`\n          \u003ch1\u003e0\u003c/h1\u003e\n        `}\n        webHandler={function webHandler(action, callRN, window) {\n          var count = parseInt(window.document.querySelector('h1').innerHTML, 10);\n          if (action.type === 'inc') {\n              window.document.querySelector('h1').innerHTML = (count + 1);\n          } else if (action.type === 'dec') {\n              window.document.querySelector('h1').innerHTML = (count - 1);\n          }\n          callRN('ack', 'message ' + action.type + ' received')\n        }}\n        rnHandler={(action, callWeb) =\u003e console.log(action.type, action.payload)}\n      \u003e \n        {({callWeb, webViewProps}) =\u003e (\n          \u003cView style={{flex: 1}}\u003e\n            \u003cWebView\n              {...webViewProps}\n              style={{flex: 1, alignSelf: 'stretch'}}\n            /\u003e\n\n            \u003cView style={{flexDirection: 'row', height: 60, justifyContent: 'space-around'}}\u003e\n              \u003cTouchableOpacity onPress={() =\u003e callWeb('inc', null)}\u003e\n                  \u003cText\u003e+1\u003c/Text\u003e\n              \u003c/TouchableOpacity\u003e\n\n              \u003cTouchableOpacity onPress={() =\u003e callWeb('dec', null)}\u003e\n                  \u003cText\u003e-1\u003c/Text\u003e\n              \u003c/TouchableOpacity\u003e\n            \u003c/View\u003e\n          \u003c/View\u003e\n        )}\n      \u003c/Html5Loader\u003e\n    );\n  }\n}\n\n```\n\n### Props\n* **head** (`string`): will be injected into the `\u003chead\u003e` section of WebView HTML.\n* **body** (`string`): will be injected into the `\u003cbody\u003e` section of WebView HTML.\n* **webHandler** (`es5 function`): the code to execute inside Web when receiving message from React Native side. The signature:\n    * **action**: JS object with format `{type, payload}` \n    * **callRN**: used to send message back to React Native side. `callRN` also has two positional params `type`(string) and `payload`(any)\n    * **window**: injected global `window` object for WebView.\n* **rnHandler** (`function`): the code to execute inside RN when receiving message from Web side. The signature:\n    * **action**: JS object with format `{type, payload}` \n    * **callWeb**: used to send message to web side. `callWeb` also has two positional params `type`(string) and `payload`(any)\n\n### props.children\n\nThis library uses `render props pattern` and the `props.children` should be a function returning `JSX`, with a single param which is an object containing following properties:\n  * **callWeb**: used to send message to web side. `callWeb` also has two positional params `type`(string) and `payload`(any)\n  * **webViewProps**: calculated props for the actual `WebView`, use spread operator to pass those props to let the magic happen!\n\n## Contributions\n\nWelcome!\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhitedogg13%2Freact-native-html5-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwhitedogg13%2Freact-native-html5-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhitedogg13%2Freact-native-html5-loader/lists"}