tomcru / holy-loader

Holy Loader is a i18n-ready, lightweight, customizable top loading progress bar component for React / Next.js 13 & Next.js 14. #toploader #top-loader #nextjs-toploader #nprogress #nextjs-progressbar
https://www.npmjs.com/package/holy-loader
MIT License
108 stars 4 forks source link

delay in loader display #22

Open rohankm opened 7 months ago

rohankm commented 7 months ago

hi im using router.push() from next/navigation. whenever I try to navigate the loader doesn't start on the go.. at the very end of the page load it starts showing.

tomcru commented 7 months ago

This is due to router.push() only firing at the end (when your page has loaded). I perceived the same behaviour when trying this out with nextjs. I'm not aware of any other events to listen to that trigger earlier. Do you have any suggestions?

rohankm commented 7 months ago

Is it better to create a new router hook where we can manually track when the router.push is run

monkeystylle commented 5 months ago

hi is there an update or fix for this? the delay when using router.push ?

tomcru commented 5 months ago

I don't believe this is possible, because the router.push event only fires once the page has already loaded. Unless you are aware of another way we could implement this.

We did, however, just add 2 new funcs with which you can manually start & stop the loader:

'use client';

import { startHolyLoader, stopHolyLoader } from 'holy-loader';

startHolyLoader();
stopHolyLoader();

So you should be able to do:

startHolyLoader();
router.push('/your-page')

Make sure you are on the latest version (2.3.1) for these to be available. You can run npm upgrade holy-loader to update.

monkeystylle commented 5 months ago

hey thanks, after reading the docs, using startHolyLoader(); before router.push works.. thanks a lot