{"id":20377770,"url":"https://github.com/rolandjitsu/react-fetch-streams","last_synced_at":"2025-04-12T07:50:28.065Z","repository":{"id":95766470,"uuid":"314715910","full_name":"rolandjitsu/react-fetch-streams","owner":"rolandjitsu","description":"React hook for the Streams API.","archived":false,"fork":false,"pushed_at":"2024-03-12T00:11:12.000Z","size":222,"stargazers_count":11,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-05T11:35:38.660Z","etag":null,"topics":["fetch-api","javascript","react","react-hook","streams-api"],"latest_commit_sha":null,"homepage":"https://rolandjitsu.github.io/react-fetch-streams/","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/rolandjitsu.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":"2020-11-21T02:25:27.000Z","updated_at":"2024-04-18T22:39:45.000Z","dependencies_parsed_at":"2024-06-20T23:27:07.144Z","dependency_job_id":"fb607ceb-dc1c-4983-bfa8-3fef8c4a63bb","html_url":"https://github.com/rolandjitsu/react-fetch-streams","commit_stats":{"total_commits":10,"total_committers":2,"mean_commits":5.0,"dds":"0.19999999999999996","last_synced_commit":"3b906f90915f6447497b9118f649538963db50a1"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rolandjitsu%2Freact-fetch-streams","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rolandjitsu%2Freact-fetch-streams/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rolandjitsu%2Freact-fetch-streams/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rolandjitsu%2Freact-fetch-streams/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rolandjitsu","download_url":"https://codeload.github.com/rolandjitsu/react-fetch-streams/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248537003,"owners_count":21120688,"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-api","javascript","react","react-hook","streams-api"],"created_at":"2024-11-15T01:46:26.292Z","updated_at":"2025-04-12T07:50:28.046Z","avatar_url":"https://github.com/rolandjitsu.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-fetch-streams\n\n\u003e A react hook for using the [Streams API](https://developer.mozilla.org/en-US/docs/Web/API/Streams_API) with the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) to stream data from a server.\n\n[![npm](https://img.shields.io/npm/v/react-fetch-streams.svg?style=flat-square)](https://www.npmjs.com/package/react-fetch-streams)\n[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/rolandjitsu/react-fetch-streams/Test?label=tests\u0026style=flat-square)](https://github.com/rolandjitsu/react-fetch-streams/actions?query=workflow%3ATest)\n[![Coveralls Github Branch](https://img.shields.io/coveralls/github/rolandjitsu/react-fetch-streams/master?style=flat-square)](https://coveralls.io/github/rolandjitsu/react-fetch-streams?branch=master)\n\n# Table of Contents\n\n* [Installation](#installation)\n* [Usage](#usage)\n* [Browser Support](#browser-support)\n* [Contribute](#contribute)\n\n### Installation\n----------------\nYou can install this package from [NPM](https://www.npmjs.com):\n```bash\nnpm add react-fetch-streams\n```\n\nOr with [Yarn](https://yarnpkg.com/en):\n```bash\nyarn add react-fetch-streams\n```\n\n#### CDN\nFor CDN, you can use [unpkg](https://unpkg.com):\n\n[https://unpkg.com/react-fetch-streams/dist/index.min.js](https://unpkg.com/react-fetch-streams/dist/index.min.js)\n\nThe global namespace for react-fetch-streams is `reactFetchStreams`:\n```html\n\u003cscript type=\"text/javascript\" src=\"https://unpkg.com/react-fetch-streams/dist/index.min.js\"\u003e\u003c/script\u003e\n\n\u003cscript type=\"text/javascript\"\u003e\n    const {useStream} = reactFetchStreams;\n    ...\n\u003c/script\u003e\n\n```\n\n### Usage\n---------\nStream some data from some server:\n```jsx\nimport React, {useCallback, useState} from 'react';\nimport {useStream} from 'react-fetch-streams';\n\nconst MyComponent = props =\u003e {\n    const [data, setData] = useState({});\n    const onNext = useCallback(async res =\u003e {\n        const data = await res.json();\n        setData(data);\n    }, [setData]);\n    useStream('http://myserver.io/stream', {onNext});\n\n    return (\n        \u003cReact.Fragment\u003e\n            {data.myProp}\n        \u003c/React.Fragment\u003e\n    );\n};\n```\n\nYou can also pass the fetch request init props using `fetchParams`:\n```jsx\nimport React, {useCallback, useState} from 'react';\nimport {useStream} from 'react-fetch-streams';\n\nconst fetchParams = {mode: 'cors'}\n\nconst MyComponent = props =\u003e {\n    const [data, setData] = useState({});\n    const onNext = useCallback(async res =\u003e {\n        const data = await res.json();\n        setData(data);\n    }, [setData]);\n    useStream('http://myserver.io/stream', {onNext, fetchParams});\n\n    return (\n        \u003cReact.Fragment\u003e\n            {data.myProp}\n        \u003c/React.Fragment\u003e\n    );\n};\n```\n\nFor more examples, please check the [tests](./src/stream.test.js).\n\n### Browser Support\n-------------------\nYou can expect this hook to work wherever the following APIs are supported:\n* [File API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API#Browser_compatibility)\n* [Streams API](https://developer.mozilla.org/en-US/docs/Web/API/Streams_API#Browser_compatibility)\n* [AbortController](https://developer.mozilla.org/en-US/docs/Web/API/AbortController#Browser_compatibility)\n* [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal#Browser_compatibility)\n\nCheck [browserslist.dev](https://bit.ly/3lSuUsQ) for an overview.\n\n### Contribute\n--------------\nIf you wish to contribute, please use the following guidelines:\n* Use [Conventional Commits](https://conventionalcommits.org)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frolandjitsu%2Freact-fetch-streams","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frolandjitsu%2Freact-fetch-streams","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frolandjitsu%2Freact-fetch-streams/lists"}