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

nextjs-progressloader

v1.2.0

Published

Next.js library to manage navigation between pages/routes with loading animation

Downloads

4,534

Readme

Next Js Progress Loader

Important context: Latter the Next.Js 13 update, router events has ben depreciated and still there's no 'next native resource' to manipulate router events as before. But this lib was build to solve this problem and bring a new way to make the UX/UI better!

Install

npm install nextjs-progressloader

yarn add nextjs-progressloader

Basic Usage

Import the animation component:

import { ProgressLoader } from 'nextjs-progressloader';

Usage with app/layout.js for app folder structure

For rendering add <ProgressLoader /> to your return() inside the <body></body> tag of RootLayout():

'use client';
import { ProgressLoader } from 'nextjs-progressloader';

export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <body>
        <ProgressLoader />
        {children}
      </body>
    </html>
  );
}
Learn more about <ProgressLoader />

Advanced Usage

If you would like to render some route with the Load Animation, use <ContainerLink /> component and our custom useRouter() hook to do it:

When render <ContainerLink /> you are required to pass a links prop which is responsible to create all the needed events to work.

And when using useRouter() a event will be emitted based on the function's param.

  • Important and required: To this feature work correctly, the links prop and the function's parameter must be equals.
  • You can render the component how many times you want and anywhere you want, being inside the <body></body>
  • Using the <ContainerLink /> next will identify the routes and will pre-render: verify the documentation

Once the links are defined, you can invoke the route wherever and whenever you want using the nickname or href.

Learn everything about the Usability flow

Example usage

import { useRouter, ContainerLink, ContainerLinkProps } from 'nextjs-progressloader';

const links: ContainerLinkProps["links"] = [
  {
    href: "/",
    nickname: "home",
  },
  {
    href: "/posts",
    nickname: "posts"
  },
  {
    href: "/login",
  },
];

export function ComponentIWantToRender(){
  const router = useRouter()

  function validateSomeThing(){
    // your validation

    //Example
    if(userLogged){
      // calling by the nickname
      router.push("home")
    }else{
      //calling by the route
      router.push("/login")
    }
  }

  return (
    <>
      <ContainerLink links={links} />;

      <button className="bg-red-500" onClick={validateSomeThing}>
        Validating something
      </button>
    </>
  )
}
Learn everything about the Usability flow

Issues

Do you have any suggestions or issue? Please let me know
Check the changelog