{"id":21270730,"url":"https://github.com/explodingcamera/react-sus","last_synced_at":"2025-03-15T12:12:25.061Z","repository":{"id":129697260,"uuid":"454388436","full_name":"explodingcamera/react-sus","owner":"explodingcamera","description":"Minimal Suspense-based data-fetching","archived":false,"fork":false,"pushed_at":"2022-02-12T21:26:32.000Z","size":237,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-22T02:32:15.643Z","etag":null,"topics":[],"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/explodingcamera.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2022-02-01T12:58:54.000Z","updated_at":"2022-02-02T00:17:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"417efdeb-610e-4eea-8c33-d7bf40e34ac5","html_url":"https://github.com/explodingcamera/react-sus","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/explodingcamera%2Freact-sus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/explodingcamera%2Freact-sus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/explodingcamera%2Freact-sus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/explodingcamera%2Freact-sus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/explodingcamera","download_url":"https://codeload.github.com/explodingcamera/react-sus/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243725634,"owners_count":20337670,"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":"2024-11-21T08:18:27.174Z","updated_at":"2025-03-15T12:12:25.055Z","avatar_url":"https://github.com/explodingcamera.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1\u003e\n  react-sus\n  \u003ca href=\"https://bundlephobia.com/result?p=react-sus@latest\"\u003e\u003cimg src=\"https://img.shields.io/bundlephobia/minzip/react-sus@latest?label=bundle%20size\u0026style=flat\u0026colorA=000000\u0026colorB=000000\"/\u003e\u003c/a\u003e\u0026nbsp;\n  \u003ca href=\"https://www.npmjs.com/package/react-sus\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/react-sus?style=flat\u0026colorA=000000\u0026colorB=000000\"/\u003e\u003c/a\u003e\n\u003c/h1\u003e\n\u003ch3\u003e\u003c/h3\u003e\n\n```bash\nnpm i react-sus\n```\n\nMinimal Suspense-based data-fetching (Currently in development and not production-ready)\n\n## Example\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003e TypeScript \u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n```tsx\nimport { Suspense } from \"react\";\nimport { sus } from \"react-sus\";\n\ninterface User {\n  username: string;\n}\n\nconst SomeComponent = ({ userID }: { userID: string }) =\u003e {\n  const data = sus\u003cUser\u003e(`https://api.example.com/user/${userID}`);\n  return \u003cdiv\u003e{data.username}\u003c/div\u003e;\n};\n\nconst App = () =\u003e (\n  \u003cSuspense fallback={\u003cdiv\u003eLoading...\u003c/div\u003e}\u003e\n    \u003cSomeComponent userID={\"example\"} /\u003e\n  \u003c/Suspense\u003e\n);\n```\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n## API\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003e Simplified API \u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n```tsx\ntype sus = \u003cData\u003e(\n  key: Key, // anything that can be serialized to a string\n  fetcher?: Fetcher | undefined,\n  userConfig?: Config\n) =\u003e Await\u003cData\u003e;\n\ninterface Config {\n  fetcher: Fetcher; // any promise or fetch-like function\n  cacheProvider: Cache; // any Map-like function\n}\n```\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\nAny Component using this function needs to be wrapped in an `\u003cSuspense\u003e\u003c/Suspense\u003e` block. Once the promise is started, control will be given back to react until the promise resolves and the actual data is returned.\n\nThe key acts as the key for caching the results, so be sure to not reuse the same cache keys for different requests (only relevant when they both use the same cacheProvider).\n\nWhen an error occours, it will bubble up to the next `\u003cErrorBoundary/\u003e`. Because of this, the return value is guaranteed to be valid.\n\n## Configuration\n\n### Context\n\n\u003e will be available at release\n\n### Pre-Loading\n\n\u003e will be available at release\n\n### Cache Busting\n\n\u003e will be available at release\n\n## Inspirations\n\nThis project seeks to combine the simplicity of swr with react-query's feature set and suspend-react's suspense support.\n\n- [swr](https://github.com/vercel/swr)\n- [suspend-react](https://github.com/pmndrs/suspend-react)\n- [react-query](https://github.com/tannerlinsley/react-query)\n\n## Related Projects\n\n- [snowstorm](https://github.com/explodingcamera/snowstorm) - The lightning-fast and minimalist React Tool\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexplodingcamera%2Freact-sus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexplodingcamera%2Freact-sus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexplodingcamera%2Freact-sus/lists"}