With this little library, you can notify your users if they have unsaved changes before accidentally closing the browser or its tab.
How to use:
npm i prevent-browser-tab-closing
or yarn add prevent-browser-tab-closing
then import it at where-ever you want to prevent user from accidentally closing the browser tab.
import confirmTabClosing from "prevent-browser-tab-closing"
or
import { confirmTabClosing } from "prevent-browser-tab-closing"