{"repo":"run4w4y/nextjs-router-events","free":true,"listed":false,"github":"https://github.com/run4w4y/nextjs-router-events","clone":"git clone https://github.com/run4w4y/nextjs-router-events.git","description":"A router events alternative for Next 13+ with app directory","language":"TypeScript","stars":42,"topics":["app-directory","navigation","nextjs","router-events","typescript"],"license":"MIT","category":"saas-starters-boilerplates","readme_excerpt":"nextjs-router-events A router events alternative for the Next.js App Router, with route lifecycle hooks and support for guarded navigation. Motivation The Pages Router exposed router events that could be used to track navigation and block a route change while the app asked for confirmation. The App Router does not provide the same API. nextjs-router-events provides a small client-side layer for common App Router navigation flows: internal links, wrapped router methods, and browser history traversal. Installation Peer dependencies are Next.js ^13 ^14 ^15 ^16 , React ^18 ^19 , and React DOM ^18 ^19 . Setup Wrap your application with RouteChangesProvider in app/layout.tsx . Use the package useRouter wrapper when navigating programmatically. The wrapper keeps the App Router API shape and adds route-event handling for push , replace , back , and forward . Other router methods, such as refresh , pass through without route-event handling. API RouteChangesProvider By default, the provider watches same-tab internal anchors except links marked with data-ignore-router-events=\"true\" . You can customize which anchors are managed with getAnchorChildren . useRouteChangeEvents Callbacks: - onBeforeRouteChange(targetUrl, detail) runs before a managed navigation is allowed to continue. Return false to block it. - onRouteChangeStart(targetUrl, detail) runs when the managed navigation commits. - onRouteChangeComplete(targetUrl, detail) runs after the App Router location changes. allowRouteChange","default_branch":null,"files":null,"tree":[],"storefront":"/r/run4w4y","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/run4w4y/nextjs-router-events/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}