{"id":18369913,"url":"https://github.com/cawfree/react-jsx-provider","last_synced_at":"2026-04-16T08:31:37.590Z","repository":{"id":88544043,"uuid":"187033057","full_name":"cawfree/react-jsx-provider","owner":"cawfree","description":"A React Provider for reliably rendering dependency-aware distributed JSX.","archived":false,"fork":false,"pushed_at":"2019-12-16T08:49:49.000Z","size":283,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-21T00:26:01.114Z","etag":null,"topics":["dynamic","javascript","jsx","native","provider","react","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cawfree.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}},"created_at":"2019-05-16T13:25:25.000Z","updated_at":"2019-12-16T08:49:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"e6263835-5f19-4937-8b3a-eeaee0db38ab","html_url":"https://github.com/cawfree/react-jsx-provider","commit_stats":{"total_commits":28,"total_committers":2,"mean_commits":14.0,"dds":0.5,"last_synced_commit":"dd1e015b5325d66b107c63e8f5835ccdf333029f"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cawfree/react-jsx-provider","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cawfree%2Freact-jsx-provider","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cawfree%2Freact-jsx-provider/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cawfree%2Freact-jsx-provider/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cawfree%2Freact-jsx-provider/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cawfree","download_url":"https://codeload.github.com/cawfree/react-jsx-provider/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cawfree%2Freact-jsx-provider/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31877465,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T07:36:03.521Z","status":"ssl_error","status_checked_at":"2026-04-16T07:35:53.576Z","response_time":69,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["dynamic","javascript","jsx","native","provider","react","react-native"],"created_at":"2024-11-05T23:33:36.977Z","updated_at":"2026-04-16T08:31:37.572Z","avatar_url":"https://github.com/cawfree.png","language":"JavaScript","funding_links":["https://www.buymeacoffee.com/cawfree"],"categories":[],"sub_categories":[],"readme":"# @cawfree/react-jsx-provider\nA React `\u003cProvider/\u003e` used to reliably rendering dependency-aware JSX. Compatible with both `react` and `react-native`.\n\n## 🤔 About\nThis library is built on top of the _awesome_ [`react-jsx-parser`](https://www.npmjs.com/package/react-jsx-parser), which is used to take a raw JSX string and render it as part of the React DOM, and adds a couple of utilities to enhance the _scalability_ and _portability_  of the JSX. This is done by defining a `package.json`-esque string which defines not only the content to render, but the necessary data dependencies of the runtime environment.\n\nIf all of the dependencies are met by the runtime, the JSX string can be injected and rendered within the DOM; otherwise, it falls back to a `renderFailure` method, which allows your app to continue as normal. Since it is backed by a [`React.createContext`](https://reactjs.org/docs/context.html) `\u003cProvider/\u003e`, these runtime dependencies can be referenced or overriden throughout the nested hierarchy.\n\n## 🚀 Getting Started\nUsing [npm](https://www.npmjs.com/package/@cawfree/react-jsx-provider)\n```\nnpm install --save @cawfree/react-jsx-provider\n```\nUsing [yarn](https://www.npmjs.com/package/@cawfree/react-jsx-provider)\n```\nyarn add @cawfree/react-jsx-provider\n```\n\n## ✍️ Example\n```javascript\nimport React from 'react';\nimport {\n  View,\n  Text,\n  StyleSheet,\n  Image,\n} from 'react-native';\n\nimport Provider, { ScriptComponent } from '@cawfree/react-jsx-provider';\n\nconst styles = StyleSheet.create({\n  container: {\n    flex: 1,\n    backgroundColor: 'white',\n  },\n  error: {\n    flex: 1,\n    backgroundColor: 'lightgrey',\n    alignItems: 'center',\n    justifyContent: 'center',\n  },\n  errorText: {\n    fontSize: 60,\n    fontWeight: 'bold',\n    color: 'white',\n  },\n});\n\n// XXX: This file contains a package.json-esque JSON which\n//      defines the dependencies of the JSX wished to embed\n//      within the application..\nconst request = require('./assets/json/package.json');\n\nexport default class App extends React.Component {\n  constructor(nextProps) {\n    super(nextProps);\n    this.__renderFailure = this.__renderFailure.bind(this);\n  }\n  // XXX: This is the fallback render method for when a \u003cScriptComponent/\u003e\n  //      fails to have its dependency requirements met.\n  __renderFailure(resolutionErrors) {\n    return (\n      \u003cView\n        style={styles.error}\n      \u003e\n        \u003cText\n          style={styles.errorText}\n        \u003e\n          {'?'}\n        \u003c/Text\u003e\n      \u003c/View\u003e\n    );\n  }\n  // XXX: Define the runtime implementations for each library dependency\n  //      that you wish to expose to a \u003cScriptComponent/\u003e.\n  __getRuntime() {\n    return {\n      ...require('./package.json'),\n      \"config\": {\n        \"react-native\": {\n          // XXX: Try commenting out some of the dependencies!\n          View,\n          Text,\n          Image,\n        },\n      },\n    };\n  }\n  render() {\n    // XXX: The Provider is used to define the runtime implementation context\n    //      for all of the child \u003cScriptComponent/\u003es. Use this at the root of\n    //      your application, or nest multiple instances to define child-specific\n    //      runtime dependencies.\n    //\n    //      The \"script\" prop is used to select which JSX string to render within\n    //      the ScriptComponent. This is defined as part of the request package.json.\n    //\n    //      Try changing it to the name of a script that doesn't exist!\n    return (\n      \u003cProvider\n        renderFailure={this.__renderFailure}\n        request={request}\n        runtime={this.__getRuntime()}\n      \u003e\n        \u003cView\n          style={styles.container}\n        \u003e\n          \u003cScriptComponent\n            script=\"Welcome\"\n          /\u003e\n        \u003c/View\u003e\n      \u003c/Provider\u003e\n    );\n  }\n}\n```\n\nCheck out the [React Native](https://facebook.github.io/react-native/) app in the examples folder for more info.\n\n## 🙏 Acknowledgements\n[react-jsx-parser](https://www.npmjs.com/package/react-jsx-parser)\n\n[semver](https://www.npmjs.com/package/semver)\n\n## ✌️ License\n[MIT](https://opensource.org/licenses/MIT)\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.buymeacoffee.com/cawfree\"\u003e\n    \u003cimg src=\"https://cdn.buymeacoffee.com/buttons/default-orange.png\" alt=\"Buy @cawfree a coffee\" width=\"232\" height=\"50\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcawfree%2Freact-jsx-provider","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcawfree%2Freact-jsx-provider","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcawfree%2Freact-jsx-provider/lists"}