Libraries relying on monkey patching router.push
no longer work with 15.3
#80574
Unanswered
wintercounter
asked this question in
App Router
Replies: 1 comment
-
My top progress bar broke. Can we I just want to show a progress bar when a navigation / server-side await / page loading is currently ongoing. This is my use case that got broken by the 15.3 update: export function NextClientProgressBar() {
const [loading, setLoading] = useOptimistic(false);
const router = useRouter();
const [, startTransition] = useTransition();
useEffect(() => {
if (router.push.name === "patched") {
return;
}
const push = router.push;
router.push = function patched(...args) {
startTransition(() => {
setLoading(true);
push.apply(history, args);
});
};
}, [router, setLoading]);
return <AnimatePresence>{loading && <GlobalProgressBar />}</AnimatePresence>;
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Link to the code that reproduces this issue
https://github.com/wintercounter/next-router-push-repro
To Reproduce
router.push
Link
no longer calls it.Current vs. Expected behavior
router.push
no longer called when usingLink
since 15.3Provide environment information
Operating System: Platform: linux Arch: x64 Version: #1 SMP PREEMPT_DYNAMIC Sat Feb 8 02:00:20 UTC 2025 Available memory (MB): 32023 Available CPU cores: 24 Binaries: Node: 23.11.0 npm: 10.9.2 Yarn: N/A pnpm: N/A Relevant Packages: next: 15.3.0 // Latest available version is detected (15.3.0). eslint-config-next: 15.3.0 react: 19.1.0 react-dom: 19.1.0 typescript: 5.8.3 Next.js Config: output: standalone
Which area(s) are affected? (Select all that apply)
Linking and Navigating
Which stage(s) are affected? (Select all that apply)
Other (Deployed)
Additional context
Many libraries are relying on monkey patching
router.push
due to the (very) limited router support Next.js provides. Since15.3
,Link
stopped usingrouter.push
from context.I understand monkey patching is an unsupported way of doing things, but there is simply no other way to handle specific cases, because Next doesn't provide any public APIs to give us control. I'd really like if it'd be considered
a. Using
router.push
again for navigation.b. Giving us APIs and Events for granular control over routing.
This was the previous code:
This is currently with 15.3:
NEXT-4532
Beta Was this translation helpful? Give feedback.
All reactions