{"id":20537394,"url":"https://github.com/socheatsok78/use-refresh-lock","last_synced_at":"2026-04-11T22:33:33.346Z","repository":{"id":42735547,"uuid":"282886211","full_name":"socheatsok78/use-refresh-lock","owner":"socheatsok78","description":"useRefreshLock - Ensure that user allow the browser to refresh","archived":false,"fork":false,"pushed_at":"2023-01-06T12:35:52.000Z","size":273,"stargazers_count":1,"open_issues_count":6,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-02T02:48:05.742Z","etag":null,"topics":["beforeunload","refresh-lock"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/use-refresh-lock","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/socheatsok78.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":"2020-07-27T12:07:25.000Z","updated_at":"2023-08-19T16:45:03.000Z","dependencies_parsed_at":"2023-02-06T02:31:33.113Z","dependency_job_id":null,"html_url":"https://github.com/socheatsok78/use-refresh-lock","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/socheatsok78%2Fuse-refresh-lock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/socheatsok78%2Fuse-refresh-lock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/socheatsok78%2Fuse-refresh-lock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/socheatsok78%2Fuse-refresh-lock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/socheatsok78","download_url":"https://codeload.github.com/socheatsok78/use-refresh-lock/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242144480,"owners_count":20078966,"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":["beforeunload","refresh-lock"],"created_at":"2024-11-16T00:40:28.617Z","updated_at":"2026-04-11T22:33:28.312Z","avatar_url":"https://github.com/socheatsok78.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# use-refresh-lock\n\nEnsure that user allow the browser to refresh\n\n[![npm-version](https://img.shields.io/npm/v/use-refresh-lock)][npm-url]\n[![npm-minzip](https://img.shields.io/bundlephobia/minzip/use-refresh-lock)][npm-url]\n[![npm-download](https://img.shields.io/npm/dm/use-refresh-lock)][npm-url]\n\n### Installation\n\n```sh\nyarn add use-refresh-lock\n```\n\n### Usage\n\nCreate a simple refresh lock\n\n```js\nimport { useRefreshLock } from 'use-refresh-lock'\n\n// create a lock\nconst release = useRefreshLock()\n\n// now when you refresh the browser, the browse will prompt an\n// 'Change you made may not be save.' prompt (aka Chrome)\n\n// release the lock, just call the `release` method returned by `useRefreshLock`\nrelease()\n```\n\nAditionally, you could provide a callback to `useRefreshLock`. Recommended to use only to call `navigator.sendBeacon` only.\n\n\u003e See: https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon\n\n```js\nimport { useRefreshLock } from 'use-refresh-lock'\n\nconst release = useRefreshLock(function() {\n    // execute before the page successfully unloaded/reloaded\n    navigator.sendBeacon(\"/log\", analyticsData);\n})\n```\n\n## License\nLicense under [MIT](LICENSE)\n\n\u003c!-- Variables --\u003e\n[npm-url]: https://www.npmjs.com/package/use-refresh-lock\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsocheatsok78%2Fuse-refresh-lock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsocheatsok78%2Fuse-refresh-lock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsocheatsok78%2Fuse-refresh-lock/lists"}