{"id":13450273,"url":"https://github.com/webscopeio/react-health-check","last_synced_at":"2026-01-14T23:12:51.034Z","repository":{"id":38426572,"uuid":"162705963","full_name":"webscopeio/react-health-check","owner":"webscopeio","description":"Lightweight React hook for checking health of API services.","archived":false,"fork":false,"pushed_at":"2023-03-06T00:30:28.000Z","size":1960,"stargazers_count":36,"open_issues_count":15,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-09-21T11:17:13.302Z","etag":null,"topics":["api","check","detect","health","hook","offline","react"],"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/webscopeio.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}},"created_at":"2018-12-21T11:24:09.000Z","updated_at":"2025-01-26T08:51:30.000Z","dependencies_parsed_at":"2024-01-07T18:04:28.813Z","dependency_job_id":"3273421e-6bb4-4c40-9a65-113e463b1c8e","html_url":"https://github.com/webscopeio/react-health-check","commit_stats":{"total_commits":143,"total_committers":8,"mean_commits":17.875,"dds":"0.49650349650349646","last_synced_commit":"5479305e31d853650fa5bc1927aa82a4ba462ec9"},"previous_names":["webscopeio/react-detect-offline-api"],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/webscopeio/react-health-check","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webscopeio%2Freact-health-check","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webscopeio%2Freact-health-check/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webscopeio%2Freact-health-check/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webscopeio%2Freact-health-check/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webscopeio","download_url":"https://codeload.github.com/webscopeio/react-health-check/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webscopeio%2Freact-health-check/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28437940,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T22:37:52.437Z","status":"ssl_error","status_checked_at":"2026-01-14T22:37:31.496Z","response_time":107,"last_error":"SSL_read: 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":["api","check","detect","health","hook","offline","react"],"created_at":"2024-07-31T07:00:33.142Z","updated_at":"2026-01-14T23:12:51.000Z","avatar_url":"https://github.com/webscopeio.png","language":"TypeScript","funding_links":[],"categories":["Packages"],"sub_categories":[],"readme":"# React Health Check 🏥\n\nLightweight React hook for checking health of API services.\n\n[![stable](https://badgen.net/npm/v/@webscopeio/react-health-check)](https://www.npmjs.com/package/@webscopeio/react-health-check)\n![tslib](https://badgen.net/npm/types/tslib)\n![checks](https://badgen.net/github/checks/webscopeio/react-health-check)\n[![license](https://badgen.now.sh/badge/license/MIT)](./LICENSE)\n\n---\n\n## Installation 🧑‍🔧\n\n```\nnpm i @webscopeio/react-health-check\n```\n\nor\n\n```\nyarn add @webscopeio/react-health-check\n```\n\n## Examples 😲\n\n- [Basic](examples/basic)\n- [Global configuration](examples/global-conf)\n\n## Usage ❓\n\n```ts\nconst { available, refresh } = useHealthCheck({\n  service: {\n    name: 'auth',\n    url: 'https://example.com/auth/health',\n  },\n  onSuccess: ({ service, timestamp }) =\u003e {\n    console.log(`Service \"${service.name}\" is available since \"${timestamp}\" 🎉`);\n  },\n  onError: ({ service, timestamp }) =\u003e {\n    console.log(`Service \"${service.name}\" is not available since \"${timestamp}\" 😔`);\n  },\n});\n```\n\nYou can also create a global configuration so you don't have to define services and callbacks every time:\n\n```tsx\n// App wrapper\n\u003cHealthCheckConfig\n  value={{\n    services: [\n      {\n        name: 'auth',\n        url: 'https://example.com/auth/health',\n      },\n      {\n        name: 'payment',\n        url: 'https://example.com/payment/health',\n      },\n    ],\n    onSuccess: ({ service, timestamp }) =\u003e {\n      console.log(`Service \"${service.name}\" is available since \"${timestamp}\" 🎉`);\n    },\n    onError: ({ service, timestamp }) =\u003e {\n      console.log(`Service \"${service.name}\" is not available since \"${timestamp}\" 😔`);\n    },\n  }}\n\u003e\n  \u003cApp /\u003e\n\u003c/HealthCheckConfig\u003e;\n\n// Later in some child component\nconst { available } = useHealthCheck('auth');\n```\n\n## Configuration 🛠\n\n`useHealthCheck()` hook accepts a configuration object with keys:\n\n| Key                | Type                                | Description                                                                                                   |\n| ------------------ | ----------------------------------- | ------------------------------------------------------------------------------------------------------------- |\n| service            | `Service\u003cS = string\u003e`               | Object defining an API service to be checked.                                                                 |\n| onSuccess          | `(state: ServiceState\u003cS\u003e) =\u003e void;` | Callback which should be called when API service becomes available again.                                     |\n| onError            | `(state: ServiceState\u003cS\u003e) =\u003e void;` | Callback which should be called when API service becomes unavailable.                                         |  |\n| refreshInterval    | `number`                            | Polling interval for health checks in milliseconds. \u003cbr\u003e **Default value: 5000**                              |\n| refreshWhileHidden | `boolean`                           | Determines whether polling should be paused while browser window isn't visible. \u003cbr\u003e **Default value: false** |\n\nGlobal configuration accepts the same keys as `useHealthCheck()` hook with the exception of \"service\". You need to specify array of \"services\" when using global configuration.\n\n## License 💼\n\nMIT | Developed by Webscope.io\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebscopeio%2Freact-health-check","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebscopeio%2Freact-health-check","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebscopeio%2Freact-health-check/lists"}