{"id":16234166,"url":"https://github.com/zackify/react-suspendable","last_synced_at":"2026-01-21T10:37:16.441Z","repository":{"id":44049524,"uuid":"219055973","full_name":"zackify/react-suspendable","owner":"zackify","description":"a function that can wrap any async action and make it compatible with suspense","archived":false,"fork":false,"pushed_at":"2023-01-04T23:56:06.000Z","size":982,"stargazers_count":1,"open_issues_count":30,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-07T20:14:46.661Z","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/zackify.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}},"created_at":"2019-11-01T20:14:31.000Z","updated_at":"2021-04-02T05:03:23.000Z","dependencies_parsed_at":"2023-02-03T00:45:34.858Z","dependency_job_id":null,"html_url":"https://github.com/zackify/react-suspendable","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zackify/react-suspendable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zackify%2Freact-suspendable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zackify%2Freact-suspendable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zackify%2Freact-suspendable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zackify%2Freact-suspendable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zackify","download_url":"https://codeload.github.com/zackify/react-suspendable/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zackify%2Freact-suspendable/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28631937,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T04:47:28.174Z","status":"ssl_error","status_checked_at":"2026-01-21T04:47:22.943Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-10-10T13:15:12.545Z","updated_at":"2026-01-21T10:37:16.424Z","avatar_url":"https://github.com/zackify.png","language":"TypeScript","readme":"# Suspender\n\nNot really meant for anything serious yet, and may never be.\n\nThis is a package that wraps async functions to be used with Suspense. You can see in the example folder how that looks.\n\n### Run the example\n\nThe example contains code that helped me get more familiar with suspense data loading. Take a look at the example/src directory.\n\n```\nyarn\nyarn start\n\n// in another tab\ncd example\nyarn\nyarn start\n```\n\n## Basic fetch\n\n```js\nimport { suspender } from 'react-suspender';\n\nconst getData = async type =\u003e {\n  if (type === 'success') {\n    let response = await fetch('https://test.com');\n    let json = await response.json();\n    return json;\n  }\n};\n\nconst initialRequest = suspender(getData, 'success');\n\nconst App = () =\u003e {\n  let [user, setUser] = React.useState(initialRequest);\n  return (\n    \u003cReact.Suspense fallback={\u003cdiv\u003esidebar loader...\u003c/div\u003e}\u003e\n      \u003cSomeComponent user={user} /\u003e\n    \u003c/React.Suspense\u003e\n  );\n};\n\nconst SomeComponent = ({ user }) =\u003e {\n  let { data, args } = user.read();\n  //args are what was passed in to the suspender / async function as the second argument\n  // data is the resulting promise result\n  return null;\n};\n```\n\n## Error Handling\n\nSee `examples/src/TestContent.tsx`. You can wrap your component in an error boundary, and then you will be able to render something if an async request throws a promise rejection\n\n## TypeScript example\n\n```js\ntype User = { name: string };\n// initial request must be created outside the render, or else you will be in an infinite loop\nconst initialRequest = suspender \u003c User \u003e (getData, 'success');\n\nconst App = () =\u003e {\n  let [user, setUser] = React.useState(initialRequest);\n  return (\n    \u003cReact.Suspense fallback={\u003cdiv\u003esidebar loader...\u003c/div\u003e}\u003e\n      \u003cSidebar user={user} /\u003e\n    \u003c/React.Suspense\u003e\n  );\n};\n\n// Example using TS types with suspense\ntype SidebarProps = {\n  user: Suspender\u003cUser\u003e,\n};\n\nconst Sidebar = ({ user }: SidebarProps) =\u003e {\n  const { data } = user.read();\n  // data is correctly typed using the User type above\n  return null;\n};\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzackify%2Freact-suspendable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzackify%2Freact-suspendable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzackify%2Freact-suspendable/lists"}