apal21 / nextjs-progressbar

A simple Next.js progressbar component using NProgress.
https://www.npmjs.com/package/nextjs-progressbar
MIT License
776 stars 61 forks source link

Request for nprogress.start() and nprogress.done() Functions to be Added to nextjs-progressbar #104

Open in-ch opened 10 months ago

in-ch commented 10 months ago

I implemented an onClick event function that allows the <Link> component to display a confirmation modal whenever the page is moved as follows.

e.preventDefault();

handleShowModal(
    commonModal({
          title: 'title',
          description: 'description',
          handleClickClose: () => {
             handleHideModal();
             NProgress.done(true);
          },
          handleClickOk: () => {
            router.replace(`${href}`);
          },
    }),
);

The issue I'm facing is that NProgress starts appearing at the top before e.preventDefault() gets executed due to <Link> component. To resolve this, I had to install nprogress and code>@types/nprogress</code additionally, which I find less than ideal.

Is it possible that nextjs-progressbar, which already includes nprogress as a dependency, supports nprogress.start() and nprogress.done() functionalities?

I'm curious if it could handle this without the need for additional installations, similar to how it's done locally.