{"id":19974476,"url":"https://github.com/yyx990803/register-service-worker","last_synced_at":"2025-05-14T12:13:15.296Z","repository":{"id":28233374,"uuid":"117010948","full_name":"yyx990803/register-service-worker","owner":"yyx990803","description":"A script to simplify service worker registration with hooks for common events.","archived":false,"fork":false,"pushed_at":"2024-04-17T09:35:04.000Z","size":100,"stargazers_count":656,"open_issues_count":22,"forks_count":58,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-05-07T22:39:18.736Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/yyx990803.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2018-01-10T21:07:58.000Z","updated_at":"2025-04-29T22:28:43.000Z","dependencies_parsed_at":"2024-06-18T11:53:58.633Z","dependency_job_id":"eb249d2b-afb1-45b7-9c07-51476a6f2c25","html_url":"https://github.com/yyx990803/register-service-worker","commit_stats":{"total_commits":58,"total_committers":18,"mean_commits":"3.2222222222222223","dds":0.6551724137931034,"last_synced_commit":"756fe7fe956b092b0afc86d55a3fd24f181f4da7"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yyx990803%2Fregister-service-worker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yyx990803%2Fregister-service-worker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yyx990803%2Fregister-service-worker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yyx990803%2Fregister-service-worker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yyx990803","download_url":"https://codeload.github.com/yyx990803/register-service-worker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253948410,"owners_count":21988953,"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-13T03:15:05.669Z","updated_at":"2025-05-14T12:13:10.278Z","avatar_url":"https://github.com/yyx990803.png","language":"JavaScript","funding_links":[],"categories":["PWA","JavaScript"],"sub_categories":[],"readme":"# register-service-worker\n\nA script to simplify service worker registration with hooks for common events.\n\n## Usage\n\n**Note:** this script uses ES modules export and is expected to be used with a client side bundler that can handle ES modules syntax.\n\n``` js\nimport { register } from 'register-service-worker'\n\nregister('/service-worker.js', {\n  registrationOptions: { scope: './' },\n  ready (registration) {\n    console.log('Service worker is active.')\n  },\n  registered (registration) {\n    console.log('Service worker has been registered.')\n  },\n  cached (registration) {\n    console.log('Content has been cached for offline use.')\n  },\n  updatefound (registration) {\n    console.log('New content is downloading.')\n  },\n  updated (registration) {\n    console.log('New content is available; please refresh.')\n  },\n  offline () {\n    console.log('No internet connection found. App is running in offline mode.')\n  },\n  error (error) {\n    console.error('Error during service worker registration:', error)\n  }\n})\n```\n\nThe `ready`, `registered`, `cached`, `updatefound` and `updated` events passes a [ServiceWorkerRegistration](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration) instance in their arguments.\n\nThe `registrationOptions` object will be passed as the second argument to [`ServiceWorkerContainer.register()`](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register#Parameters)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyyx990803%2Fregister-service-worker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyyx990803%2Fregister-service-worker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyyx990803%2Fregister-service-worker/lists"}