{"id":22733308,"url":"https://github.com/evargast/browsernavigationwarning","last_synced_at":"2025-03-30T01:45:11.670Z","repository":{"id":42704978,"uuid":"298066653","full_name":"evargast/browserNavigationWarning","owner":"evargast","description":null,"archived":false,"fork":false,"pushed_at":"2023-01-06T14:45:43.000Z","size":904,"stargazers_count":0,"open_issues_count":12,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-27T01:43:09.104Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/browser-navigation-warning","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/evargast.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-09-23T18:58:05.000Z","updated_at":"2020-09-23T22:01:20.000Z","dependencies_parsed_at":"2023-02-06T05:32:23.103Z","dependency_job_id":null,"html_url":"https://github.com/evargast/browserNavigationWarning","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":"evargast/simple-npm-module","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evargast%2FbrowserNavigationWarning","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evargast%2FbrowserNavigationWarning/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evargast%2FbrowserNavigationWarning/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evargast%2FbrowserNavigationWarning/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/evargast","download_url":"https://codeload.github.com/evargast/browserNavigationWarning/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246266250,"owners_count":20749754,"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-12-10T20:13:41.131Z","updated_at":"2025-03-30T01:45:11.650Z","avatar_url":"https://github.com/evargast.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Browser Navigation Warning\n\n\u003ca href=\"https://www.npmjs.com/package/browser-navigation-warning\"\u003e\n    \u003cimg alt=\"npm\" src=\"https://img.shields.io/npm/v/browser-navigation-warning.svg?style=flat-square\"\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://www.npmjs.com/package/browser-navigation-warning\"\u003e\n    \u003cimg alt=\"npm\" src=\"https://img.shields.io/npm/dt/browser-navigation-warning?style=flat-square\"\u003e\n\u003c/a\u003e\n\n_Helpful utility function that will trigger the browsers default pop-up before navigating away._\n\n![Reload warning screenshot][reload]\n![Leave warning screenshot][leave]\n\n## Installation\n\n```javascript\nnpm install -D browser-navigation-warning\n```\n\n## Usage\n\nThis function takes in one parameter, `trigger` (boolean) - this sets whether the navigation warning should be enabled/disabled.\n\n\u003e `trigger = true` will not trigger the alert immediately.\u003cbr/\u003e\n\u003e It **enables** the alert which will only be triggered when the user tries to use a browser action such as _refresh_, _previous page_ or _next page_.\n\n\u003cbr/\u003e\n\n### Static - always enabled\n\nTo have the warning ready in all your pages, add the line below in your root file of your application (Usually `App`).\n\nOtherwise, add the line below to the specific pages / components you want.\n\n```javascript\nimport triggerBrowserWarning from 'browser-navigation-warning';\n\ntriggerBrowserWarning(true);\n```\n\n\u003cbr/\u003e\n\n### Dynamic - conditionally enabled\n\nAdd the snippet below to your target page / component. `trigger` is your dynamic boolean conditional that decides whether the warning should be displayed or not.\n\nReact example:\n\n```javascript\nimport triggerBrowserWarning from 'browser-navigation-warning';\n\nuseEffect(() =\u003e {\n  triggerBrowserWarning(trigger);\n}, [trigger]);\n```\n\n[\u003e More info on useEffect here \u003c](https://reactjs.org/docs/hooks-effect.html)\n\n\u003cbr/\u003e\n\n## FAQ:\n\n##\n\n**Q:** Can I have my own custom dialog or custom text?\n\n**A:** Nope, unfortunately browsers stopped supporting custom alert messages for navigation\n\n\u003cbr/\u003e\n\n**Q:** I've got an idea to improve this function, how can I get it to you?\n\n**A:** Awesome! Check the contributing section below!😄\n\n\u003cbr/\u003e\n\n## Contributing\n\n[PRs](https://github.com/evargast/browserNavigationWarning/pulls) are welcome!\n\n[Issues](https://github.com/evargast/browserNavigationWarning/issues) are also welcome!\n\n[reload]: https://raw.githubusercontent.com/evargast/browserNavigationWarning/master/readme-assets/reload.png\n[leave]: https://raw.githubusercontent.com/evargast/browserNavigationWarning/master/readme-assets/leave.png\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevargast%2Fbrowsernavigationwarning","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevargast%2Fbrowsernavigationwarning","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevargast%2Fbrowsernavigationwarning/lists"}