{"id":15019724,"url":"https://github.com/backmesh/anthropic-react-native","last_synced_at":"2025-10-24T16:31:21.617Z","repository":{"id":256315928,"uuid":"854840984","full_name":"backmesh/anthropic-react-native","owner":"backmesh","description":"Anthropic API React Native Client without polyfills","archived":false,"fork":false,"pushed_at":"2024-09-10T01:58:46.000Z","size":1551,"stargazers_count":11,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-01-31T03:13:28.318Z","etag":null,"topics":["anthropic","anthropic-claude","react-native"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/anthropic-react-native","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/backmesh.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-09T21:37:47.000Z","updated_at":"2025-01-22T04:44:01.000Z","dependencies_parsed_at":"2024-09-10T05:23:50.899Z","dependency_job_id":null,"html_url":"https://github.com/backmesh/anthropic-react-native","commit_stats":null,"previous_names":["backmesh/anthropic-react-native"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/backmesh%2Fanthropic-react-native","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/backmesh%2Fanthropic-react-native/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/backmesh%2Fanthropic-react-native/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/backmesh%2Fanthropic-react-native/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/backmesh","download_url":"https://codeload.github.com/backmesh/anthropic-react-native/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237999726,"owners_count":19399930,"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":["anthropic","anthropic-claude","react-native"],"created_at":"2024-09-24T19:53:56.650Z","updated_at":"2025-10-24T16:31:21.612Z","avatar_url":"https://github.com/backmesh.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Anthropic React Native Client\n\nThe goal of this library is to use [React Native SSE](https://github.com/binaryminds/react-native-sse) instead of polyfills to support calling the Anthropic API directly from React Native with streaming. The package uses the same types and API as the [Anthropic Node SDK](https://github.com/anthropics/anthropic-sdk-typescript) wherever possible.\n\n\u003e [!CAUTION]\n\u003e You should never expose any secrets in the bundle of a web or mobile app. The correct usage of this client package is with a backend that proxies the Anthropic call while making sure access is secured. The `baseURL` parameter for this Anthropic client is thus mandatory. If you set the baseURL to https://api.anthropic.com/v1, you are basically exposing your Anthropic API key on the internet! This example in this repo uses [Backmesh](https://backmesh.com).\n\n### Contributions and Feature Requests\n\nIf you would like to contribute or request a feature, please join our [Discord](https://discord.com/invite/FfYyJfgUUY) and ask questions in the **#oss** channel or create a pull request or issue.\n\n### Setup\n\nInstall the package\n\n```bash\nnpm i anthropic-react-native\n```\n\nAnd then instantiate the client:\n\n```typescript\nimport Anthropic from 'anthropic-react-native';\n\nconst client = new Anthropic({\n  baseURL:\n    'https://edge.backmesh.com/v1/proxy/PyHU4LvcdsQ4gm2xeniAFhMyuDl2/yWo35DdTROVMT52N0qs4/',\n  // The backmesh proxy uses your auth provider's JWT to authorize access\n  apiKey: supabase.auth.session().access_token,\n});\n```\n\n### Usage\n\nThe streaming APIs uses an [EventSource](https://developer.mozilla.org/en-US/docs/Web/API/EventSource) from [react-native-sse](https://github.com/binaryminds/react-native-sse) under the hood to provide a required typed event callbacks for each of the [Anthropic API Types](https://docs.anthropic.com/en/api/messages-streaming#event-types).\n\n```typescript\nclient.messages.stream(\n  {\n    model: 'claude-3-5-sonnet-20240620',\n    messages: [{ role: 'user', content: userInput }],\n    max_tokens: 1024,\n  },\n  {\n    onError: (error) =\u003e {\n      console.error('SSE Error:', error); // Handle any errors here\n    },\n    onMessageStart: () =\u003e {\n      setUserInput('');\n    },\n    onContentBlockDelta: (ev: ContentBlockDeltaEvent) =\u003e {\n      if (ev.delta.type === 'text_delta')\n        setText((prevText) =\u003e prevText + (ev.delta as TextDelta).text);\n    },\n    onMessageStop: () =\u003e {\n      console.log('SSE connection for completion closed.'); // Handle when the connection is opened\n    },\n  }\n);\n```\n\nCheck the [example](https://github.com/backmesh/anthropic-react-native/blob/main/sample/app/index.tsx) for more details\n\n## Coverage\n\n- [x] [Messages](https://docs.anthropic.com/en/api/messages)\n\n### License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbackmesh%2Fanthropic-react-native","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbackmesh%2Fanthropic-react-native","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbackmesh%2Fanthropic-react-native/lists"}