JSPM

nextjs-progressbar2

0.0.15
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q12637F
  • License MIT

Nprogress component for Next.js app.

Package Exports

  • nextjs-progressbar2
  • nextjs-progressbar2/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (nextjs-progressbar2) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Next.js Progressbar

A simple Next.js progressbar component using NProgress.

I've created this Blog to help you create your own progressbar

Demo: https://demo-nextjs-progressbar.vercel.app

How to install?

npm i nextjs-progressbar

How to use?

After installing the package, import NextNProgress in your pages/_app.js file:

import NextNProgress from "nextjs-progressbar";

And for rendering add <NextNProgress /> to your return() in MyApp():

import NextNProgress from "nextjs-progressbar";

export default function MyApp({ Component, pageProps }) {
  return (
    <>
      <NextNProgress />
      <Component {...pageProps} />;
    </>
  );
}

Default Config

If no props are passed to <NextNProgress />, below is the default configuration applied.

<NextNProgress
  color="#29D"
  startPosition={0.3}
  stopDelayMs={200}
  height={3}
  showOnShallow={true}
/>
  • color: to change the default color of progressbar. You can also use rgb(,,) or rgba(,,,).
  • startPosition: to set the default starting position : 0.3 = 30%.
  • stopDelayMs: time for delay to stop progressbar in ms.
  • height: height of progressbar in px.
  • showOnShallow: You can choose whether you want the progressbar to be displayed if you're using shallow routing. It takes a boolean. Learn more about shallow routing in Next.js docs.

Advanced Config

Adding nonce

We use internal css in this package. If you are using csp, you can add nonce to the <style> tag by providing nonce prop to <NextNProgress /> component.

<NextNProgress nonce="my-nonce" />

Other Configs

You can use other configurations which NProgress provides by adding a JSON in options props.

<NextNProgress options={{ easing: "ease", speed: 500 }} />