{"id":27127283,"url":"https://github.com/u4aew/react-pwa-push-notifications","last_synced_at":"2025-10-26T02:19:05.891Z","repository":{"id":195410171,"uuid":"692680549","full_name":"u4aew/react-pwa-push-notifications","owner":"u4aew","description":"React hook for push-notifications","archived":false,"fork":false,"pushed_at":"2024-11-08T21:04:14.000Z","size":1842,"stargazers_count":44,"open_issues_count":0,"forks_count":7,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-11T02:09:36.288Z","etag":null,"topics":["ios","notifications","pwa","react"],"latest_commit_sha":null,"homepage":"https://push.fancyapp.site","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/u4aew.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2023-09-17T08:47:30.000Z","updated_at":"2025-08-15T18:17:33.000Z","dependencies_parsed_at":"2023-09-23T07:21:49.154Z","dependency_job_id":"e0337742-9942-4aee-872f-b97ac49fa52d","html_url":"https://github.com/u4aew/react-pwa-push-notifications","commit_stats":null,"previous_names":["u4aew/react-hook-pwa-push-notifications","u4aew/react-pwa-push-notifications"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/u4aew/react-pwa-push-notifications","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/u4aew%2Freact-pwa-push-notifications","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/u4aew%2Freact-pwa-push-notifications/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/u4aew%2Freact-pwa-push-notifications/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/u4aew%2Freact-pwa-push-notifications/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/u4aew","download_url":"https://codeload.github.com/u4aew/react-pwa-push-notifications/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/u4aew%2Freact-pwa-push-notifications/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281047752,"owners_count":26435127,"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","status":"online","status_checked_at":"2025-10-26T02:00:06.575Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["ios","notifications","pwa","react"],"created_at":"2025-04-07T16:55:17.322Z","updated_at":"2025-10-26T02:19:05.862Z","avatar_url":"https://github.com/u4aew.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![npm version](https://badge.fury.io/js/react-hook-webauthn.svg)](https://badge.fury.io/js/react-pwa-push-notifications)\n# React hook Push Notifications\n\n## Overview\n\nThis package provides a custom React hook for facilitating push subscriptions in your application. It ensures proper handling of browser APIs and returns easy-to-handle errors in case of issues.\n\n![demo](./img/demo.gif)\n## Installation\n\n```bash\nnpm install react-pwa-push-notifications\n```\n\n## Usage\n\nWe will be using a library for Node.js called [web-push](https://github.com/web-push-libs/web-push). This library works well with Google Cloud Messaging, a system from Google for sending notifications.\nA detailed setup process can be read in this [article](https://dev.to/u4aew/how-to-set-up-push-notifications-in-safari-on-ios-ki9).\n\n```typescript\nimport { useSubscribe } from \"react-pwa-push-notifications\";\n// Import the useSubscribe function and set the public key (PUBLIC_KEY)\nconst { getSubscription } = useSubscribe({publicKey: PUBLIC_KEY});\n\n// Handler for subscribing to push notifications\nconst onSubmitSubscribe = async (e) =\u003e {\n    try {\n        // Retrieve the subscription object using the getSubscription function\n        const subscription = await getSubscription();\n\n        // Send the subscription object and ID to the server to register the subscription\n        await axios.post('/api/subscribe', { subscription });\n\n        // Display a message in case of successful subscription\n        console.log('Subscribe success');\n    } catch (e) {\n        // Display a warning in case of an error\n        console.warn(e);\n    }\n};\n```\n\n## Error Handling\n\nThe hook provides an `Errors` enum for better error management. It includes the following error codes:\n\n- `ServiceWorkerAndPushManagerNotSupported`: The service worker or push manager is not supported by the browser.\n- `PushManagerUnavailable`: The PushManager is unavailable.\n- `ExistingSubscription`: An existing subscription is already present.\n- `Unknown`: An unknown error has occurred.\n\n## Contributing\n\nFeel free to open issues or pull requests if you want to improve this package.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fu4aew%2Freact-pwa-push-notifications","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fu4aew%2Freact-pwa-push-notifications","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fu4aew%2Freact-pwa-push-notifications/lists"}