{"id":15316645,"url":"https://github.com/albert-gao/react-native-fetch-sse","last_synced_at":"2026-01-06T22:48:05.339Z","repository":{"id":215088436,"uuid":"734122378","full_name":"Albert-Gao/react-native-fetch-sse","owner":"Albert-Gao","description":"consume text-stream response with standard fetch, works with any custom server and OpenAI API.","archived":false,"fork":false,"pushed_at":"2024-01-02T13:13:32.000Z","size":1472,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-01T21:13:04.258Z","etag":null,"topics":["fetch","react","react-native","sse","streaming"],"latest_commit_sha":null,"homepage":"","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/Albert-Gao.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2023-12-20T23:28:56.000Z","updated_at":"2025-01-11T09:35:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"768ede01-0cd3-4a3c-9afb-d486a21cb90d","html_url":"https://github.com/Albert-Gao/react-native-fetch-sse","commit_stats":{"total_commits":11,"total_committers":1,"mean_commits":11.0,"dds":0.0,"last_synced_commit":"ea6df038f27e046d9f3af3ce8fe451e0daf03c71"},"previous_names":["albert-gao/react-native-fetch-sse"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Albert-Gao%2Freact-native-fetch-sse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Albert-Gao%2Freact-native-fetch-sse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Albert-Gao%2Freact-native-fetch-sse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Albert-Gao%2Freact-native-fetch-sse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Albert-Gao","download_url":"https://codeload.github.com/Albert-Gao/react-native-fetch-sse/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245898282,"owners_count":20690459,"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":["fetch","react","react-native","sse","streaming"],"created_at":"2024-10-01T08:54:36.766Z","updated_at":"2026-01-06T22:48:05.296Z","avatar_url":"https://github.com/Albert-Gao.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-native-fetch-sse\n\nconsume text-stream response with standard fetch, works with any custom server and OpenAI API.\n\n- Implemented using native `fetch()`, so you can pass headers, different Http methods, `AbortController`, etc.\n- minimal implementation, great for web only projects also\n- works on React Native / Web\n- included all polyfills (only for Native, web doesn't need them)\n\n## Installation\n\n```sh\nnpm install react-native-fetch-sse\n```\n\n## Usage\n\n```js\nimport { fetchSSE } from 'react-native-fetch-sse';\n\n// in a onPress() handler\n\nconst onPress = async () =\u003e {\n  fetchSSE(\n    '/chat-stream',\n    {\n      method: 'POST',\n      headers: {\n        Authorization: 'my-token',\n      },\n    },\n    {\n      onStart() {\n        console.log('it starts');\n      },\n\n      onMessage(data) {\n        console.log('receiving event', data);\n      },\n\n      onError(error, { status, statusText }) {\n        console.log('error', error);\n        console.log('http status code', status);\n        console.log('http statusText', statusText);\n      },\n\n      onEnd() {\n        console.log('the stream finished');\n      },\n\n      // if you are streaming done JSON,\n      // set this to true will receive the object instead of a string\n      shouldParseJsonWhenOnMsg: true,\n    },\n  );\n};\n```\n\n## Contributing\n\nSee the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.\n\n## Inspired by\n\n- [Azure/fetch-event-source](https://github.com/Azure/fetch-event-source)\n- [Vercel/AI](https://github.com/vercel/ai)\n\n## License\n\nMIT\n\n---\n\nMade with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falbert-gao%2Freact-native-fetch-sse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falbert-gao%2Freact-native-fetch-sse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falbert-gao%2Freact-native-fetch-sse/lists"}