About nextjs-nav-guard

nextjs-nav-guard is an open-source TypeScript library for protecting unsaved changes in Next.js App Router applications. It provides NavigationGuardProvider and useNavigationGuard so a form or editor can ask for confirmation before the user leaves. The documentation covers setup, custom confirmation dialogs, navigation types, and browser limitations.

Brett Schneider maintains this package as a fork of next-navigation-guard, originally created by LayerX Inc. This fork focuses on the App Router. Pages Router support has been removed. The source, changes, and issue tracker are public on GitHub, and the package is distributed through npm under the MIT license.

Use the compatibility and limitations sections in the documentation when evaluating the library for your application. Navigation guards help prevent accidental data loss, but do not save form data or replace application authorization. Check the source and test the navigation paths your application uses before shipping an integration.