-
-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NextTopLoader stopped working on Nextjs 14.0.3 #56
Comments
Same here. the progress bar is stuck at the end and never finishes loading since NextJS 14.0.3. It also looks less snappy, if that makes sense. At the time where it previously completed loading, it now goes to around at 60-70% progress and slowly crawls its way to the end, but doesn't stop loading. |
+1 |
Same problem for me. Downgrading to 14.0.2 fixed it. |
Next js 14.0.3 added experimental support for history.pushState and history.replaceState. That's why it's messing with history.pushState() method in the code. |
same problem. |
+1 |
I got the same problem, how can we solve it ? |
+1 |
|
same here |
Possible fix: run NProgress.done() inside your top level client component, this will cleanup any stuck loader
|
This works for now. |
+1 |
1 similar comment
+1 |
why root layout client-side rendering? I hope it is not good practiche |
@besufkadmenji is only talking about your top most client component not root layout client side rendering. If this is your root layout, fine. For me it is not but instead two or three pages that are the top most client components. |
same problem here |
Yep this worked for me. But we need proper fix. Thanks for suggesting. |
Also facing problem with nextjs 14. I am still using it because there is no such alternative to it. All other all manual. |
Thank you so much! My root layout looks like this: <html lang={language} dir={dir}>
<body>
<div>
<Providers locale={language}>
<NextTopLoader {...} />
{children}
// ... So that's a really good workaround, imo. |
Potentially will be fixed by vercel/next.js#58861 |
Fixed by vercel/next.js#58861 and released in v14.0.4-canary.37. |
@ajsystem , I checked the latest Nextjs v14.0.4. and nextjs-toploader works fine in that version. I think this issues should be closed now |
let see what other people opinions first, just to make sure before it's closed😉 |
@ImamAlfariziSyahputra @Super-Kenil Yep issue is fixed in v14.0.4 for my app expense.fyi |
@ImamAlfariziSyahputra . I had already tested it in 3 of my projects, then I commented here. |
Fixed! |
Still experiencing the stuck loader when its 99% done. This is happening specifically when using the custom
|
Still not working :(
|
my solutions // NextTopLoader.tsx
'use client';
import Loader from 'nextjs-toploader';
import { usePathname } from 'next/navigation';
const NextTopLoader = () => {
const pathname = usePathname();
useEffect(() => {
NProgress.done();
}, [pathname]);
return (
<Loader />
)
} // useRouter.ts
import { NavigateOptions } from 'next/dist/shared/lib/app-router-context.shared-runtime';
import { useRouter as useNextRouter, usePathname } from 'next/navigation';
import { useCallback } from 'react';
import NProgress from 'nprogress';
export const useRouter = () => {
const router = useNextRouter();
const pathname = usePathname();
const replace = useCallback(
(href: string, options?: NavigateOptions) => {
href !== pathname && NProgress.start();
router.replace(href, options);
},
[router, pathname],
);
const push = useCallback(
(href: string, options?: NavigateOptions) => {
href !== pathname && NProgress.start();
router.push(href, options);
},
[router, pathname],
);
return {
...router,
replace,
push,
};
}; |
I am using nextjs-toploader, With same version you're using, Both Next and nextjs-toploader and it seems to be working perfectly on my end. For fixing it, make sure you are not using it multiple times unnecessarily in your App. |
It works for me. Thanks for your solution ! |
this works for the latest nextjs |
this works |
Solution given by @sho-pb is perfect and works well and you can also do all the customization to the loader in the NextTopLoader.tsx file by adding the props there in the return. |
@sho-pb Hi! Is your solution also working with the browser back button? :) |
Hello, just to report that on a project with the last Nextjs 14.0.3, the toploader keeps loading and never finish or completes.
But there aren't errors on console server/client.
As a workaround to get it working install 14.0.2
The text was updated successfully, but these errors were encountered: