{"id":25595480,"url":"https://github.com/polywrap/react","last_synced_at":"2026-04-15T03:30:20.094Z","repository":{"id":64961650,"uuid":"580043181","full_name":"polywrap/react","owner":"polywrap","description":"A React library that simplifies the integration of Polywrap wrappers into React applications","archived":false,"fork":false,"pushed_at":"2023-09-18T07:32:02.000Z","size":1064,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-03T14:06:22.227Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/polywrap.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":".github/CODEOWNERS","security":null,"support":null}},"created_at":"2022-12-19T15:21:12.000Z","updated_at":"2022-12-19T16:43:36.000Z","dependencies_parsed_at":"2023-02-16T19:00:33.635Z","dependency_job_id":null,"html_url":"https://github.com/polywrap/react","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polywrap%2Freact","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polywrap%2Freact/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polywrap%2Freact/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polywrap%2Freact/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/polywrap","download_url":"https://codeload.github.com/polywrap/react/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239708984,"owners_count":19684165,"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":[],"created_at":"2025-02-21T11:29:17.946Z","updated_at":"2026-04-15T03:30:20.032Z","avatar_url":"https://github.com/polywrap.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @polywrap/react\n\nA React library that simplifies the integration of Polywrap wrappers into React applications. Instantiates the Polywrap Client, send WRAP invocations, and renders the results.\n\n## Documentation\nhttps://docs.polywrap.io/reference/clients/js/libraries/react\n\n## Installation\n\n```bash\nnpm install @polywrap/react\n```\n\n## Usage\n\n### **PolywrapProvider**\n\nOnce installed, the first step is to add the `PolywrapProvider` to your DOM. This will instantiate an instance of the `PolywrapClient` for all queries within the nested DOM hierarchy to use.\n\nTo use the provider, simply wrap it around whatever DOM hierarchy you'd like to use Polywrap within:\n\n```jsx\nimport React from 'react';\nimport { PolywrapProvider } from '@polywrap/react';\n\nexport const App: React.FC = () =\u003e {\n  return (\n    \u003cPolywrapProvider\u003e\n        \u003cHelloWorld /\u003e\n    \u003c/PolywrapProvider\u003e\n  );\n};\n```\n\n#### **PolywrapProvider Props**\n\nThe `PolywrapProvider` component's props are the same as the `PolywrapClient` constructor's arguments. For example, you can configure URI redirects like so:\n\n```jsx\n\u003cPolywrapProvider redirects={ [] }/\u003e\n```\n\n#### **Multiple PolywrapProviders**\n\nIf you need to use multiple providers, you can do so using the `createPolywrapProvider(\"...\")` method, which accepts the name of your provider as an argument. For example:\n\n```jsx\nimport { createPolywrapProvider } from '@polywrap/react';\n\nconst CustomPolywrapProvider = createPolywrapProvider('custom');\n\nexport const CustomProvider = ({ children }: { children: JSX.Element }) =\u003e {\n  return (\n    \u003cCustomPolywrapProvider\u003e\n      {children}\n    \u003c/CustomPolywrapProvider\u003e\n  );\n};\n```\n\n### **usePolywrapClient**\n\nYou can obtain a copy of the client instance from your `PolywrapProvider` using the `usePolywrapClient` hook.\n\n```jsx\nconst client = usePolywrapClient();\n```\n\n### **usePolywrapInvoke**\n\nAfter enabling your React application with the PolywrapProvider, you may now use the `usePolywrapInvoke` hook to call into wrappers!\n\n```jsx\nconst { execute, data, error, loading } = usePolywrapInvoke({\n  uri: 'ens/helloworld.polytest.eth',\n  method: \"logMessage\",\n  args: {\n    message: \"Hello World!\",\n  },\n});\n```\n\nBy default, the `usePolywrapInvoke` hook uses the first PolywrapProvider found in the DOM's hierarchy. If you'd like to specify a specific provider to be used, simply set the `provider:` property:\n\n```jsx\nconst { execute, data, error, loading } = usePolywrapInvoke({\n  provider: \"custom\",\n  uri: 'ens/helloworld.polytest.eth',\n  method: \"logMessage\",\n  args: {\n    message: \"Hello World!\",\n  },\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpolywrap%2Freact","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpolywrap%2Freact","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpolywrap%2Freact/lists"}