npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

next13-progressbar

v1.2.1

Published

A ProgressBar for next.js >=13 with app directory

Downloads

24,350

Readme

Next.js 13 Progressbar

A simple Next.js progressbar component using NProgress with support of next.js 13 and later app dir.

Demo: https://next13-progressbar.vercel.app/

How to install?

npm i next13-progressbar

How to use?

⚠️ Note : This docs are for versions >=1.0.0 only. For the older versions check tags versions tree's Readme of the older version.

After installing the package, create providers.tsx file in app directory to handle contexts and mark it use client. see contexts in app dir and import `Next13ProgressBar;

'use client';
import React from 'react';
import { Next13ProgressBar } from 'next13-progressbar';

const Providers = ({ children }: { children: React.ReactNode }) => {
  return (
    <>
      {children}
      <Next13ProgressBar height="4px" color="#0A2FFF" options={{ showSpinner: true }} showOnShallow />
    </>
  );
};

export default Providers;

Wrap your providers in layout.tsx/js

import Providers from './providers';

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en">
      <body>
        <Providers>{children}</Providers>
      </body>
    </html>
  );
}

By default all a tags are handled by next/link so you don't need to do anything.

import Link from 'next/link';
import { useRouter } from 'next13-progressbar';

const NavBar = () => {
  const router = useRouter();
  return (
    <div className="navbar">
      <Link href={'/'}>Home</Link>
      <Link href={'/about'}>About</Link>
      <Link href={'/contact'}>Contact</Link>
      <button onClick={() => router.push('/button-link')}>ButtonLink</button>
    </div>
  );
};

Default Config

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

<Next13ProgressBar 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%.
  • delay: time for delay to start progressbar in ms.
  • 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 <NProvider /> component.

<Next13ProgressBar nonce="my-nonce" />

Custom CSS

You can pass custom css to the progressbar by using style prop.

<Next13ProgressBar
  style={`
    #nprogress {
      pointer-events: none;
    }
  `}
/>

Older Versions

Check Branches with v prefix for older docs of the package. If not found check tags versions tree's Readme of the older version.

Contributing

Any Contribution of any kind are appreciated. You can start by forking this repository and make your changes then submit a pull request

Author

Support

Your support matters. It pushes me to do more Open Source contributions and give back to the community.