• Stars
    star
    786
  • Rank 57,890 (Top 2 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created almost 6 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A simple Next.js progressbar component using NProgress.

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" />

Custom CSS

You can use transformCSS prop to pass custom css. Note: You must return a JSX.Element from the function.

<NextNProgress
  transformCSS={(css) => {
    // css is the default css string. You can modify it and return it or return your own css.
    return <style>{css}</style>;
  }}
/>

Other Configs

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

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

More Repositories

1

Vue.js-VueRouter-multiple-subdomains

A sample Vue template to use single Vue.js application over multiple domains/subdomains.
JavaScript
20
star
2

target-blank-vulnerabilities-features

Examples of some features and the vulnerabilities that can exploit any webpage if target="_blank" is used without rel="noopener"
HTML
16
star
3

PHP-Laravel-5.4-custom-blog-CMS

PHP/Laravel 5.4 custom blogging CMS. CRUD operations with UI.
PHP
8
star
4

demo-nextjs-progressbar

Nextjs Progressbar demo
JavaScript
6
star
5

express-jwt-auth-server

Express.js JWT Auth Server with Babel and ESLint Airbnb, MongoDB and Redis.
JavaScript
5
star
6

nodejs-websocket-simple-chat-with-auth-key

HTML
5
star
7

Telegram-Bot-Custom-Keyboard-Node.js

A Telegram bot with Custom Keyboard and which replies you with your message. An Echo Bot.
JavaScript
3
star
8

Raspberry-pi-LED-blink-node.js

Raspberry pi LED blinking using GPIO pins in node.js
JavaScript
2
star
9

Leaflet-Before-After-Map-Comparison-Slider

This is the demo showing how we can use 2 different Leaflet Maps to compare, or display side by side to show a before-after effect or something similar to that.
JavaScript
2
star
10

apal21.github.io

JavaScript
1
star
11

Raspberry-Pi-DHT11-Node.js

Get DHT11 Temperature and Humidity reading in Raspberry Pi using Node.js
JavaScript
1
star
12

Telegram-Bot-with-Authentication-and-Custom-Keyboard

Telegram Echo Bot with Authentication and Custom Keyboard.
JavaScript
1
star
13

SQS-Delayed-Notification

Amazon SQS wrapper for delayed notification that can be used for exponential back off for applications such as custom callbacks or webhooks
TypeScript
1
star
14

express-babel-boilerplate

Minimal Production ready Express.js Babel(ES6+) boilerplate with ESLint Airbnb setup and pre commit hooks and also example routes and tests using Mocha and Supertest
JavaScript
1
star