New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

react-top-progress

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-top-progress

A lightweight modern top loading progress bar for React

latest
Source
npmnpm
Version
1.1.1
Version published
Weekly downloads
23
2200%
Maintainers
1
Weekly downloads
 
Created
Source

react-top-progress

npm version downloads license

👉 View Live Demo

A lightweight, modern, and performant top loading progress bar for React. Built for seamless user experiences with zero dependencies!

Perfect for Next.js App Router, Vite, and standard SPA architectures.

🚀 Why react-top-progress?

  • SSR & App Router Safe: Fully compatible with Next.js SSR & App Router natively
  • Framework Agnostic: Works perfectly in React, Vite, CRA, Remix, React Router
  • 0 Dependencies: No weird transitive bloat
  • 📦 Tiny Bundle Size: ~1.9kb gzipped (Tree-shakable)
  • Premium Aesthetics: Smooth realistic loading animation with beautiful gradients & glows
  • Promise Integrations: Auto-wrapping utilities like withProgress for API fetching

Installation

npm install react-top-progress

Quick Start (Next.js / Vite / React)

This approach automatically provides all routing configurations and is incredibly clean.

import { ProgressProvider, useAutoProgress } from "react-top-progress";

export default function RootLayout({ children }) {
  // Use generic auto-route progress detector or just trigger global effects
  // Optional but recommended for easy routing coverage!

  return (
    <ProgressProvider color="#29D" height={3} shadow={true}>
      {children}
    </ProgressProvider>
  );
}

Method 2: Next.js App Router Generic Auto-Routing

Because Next.js App Router removed native router events, you can quickly auto-wire progress with the useRouteProgress hook, which intrinsically detects all link navigation globally using zero-external dependencies!

"use client";

import { TopProgress, useRouteProgress } from "react-top-progress";

export default function Layout({ children }) {
  useRouteProgress(); // Auto-detects clicks, routing events, and history pushState!

  return (
    <>
      <TopProgress
        height={4}
        color="linear-gradient(90deg, #ff5500, #ff0080)"
      />
      {/* Your Top Nav, Sidebar, etc. */}
      {children}
    </>
  );
}

Built-in Methods

You can trigger the loader from anywhere in your codebase by importing the functions globally, or via a React ref assigned to <TopProgress ref={myRef} />.

MethodParametersDescription
start(loaderType?)"continuous" | "static"Starts the loading indicator. Default is continuous.
continuousStart(startingValue?, refreshRate?)number, numberStarts with a random value (20-30), then slowly ticks up (2-10) repetitively. Reaches max 90%.
staticStart(startingValue?)numberStarts the loader with a random static value between 30-50, waiting for completion.
complete() / finishProgress()Instantly pushes the indicator to 100% and gracefully fades it out.
resetProgress()Instantly zeroes out and hides the progress bar without fading.
increase(value)numberManually increments the loader by a specific amount.
decrease(value)numberManually decrements the loader by a specific amount.
setProgress(value)numberHardsets to a specific progress percentage.
getProgress()Returns the current progress percentage (0 - 100).
withProgress(promise)Promise<T>Wraps an asynchronous action. startProgress() executes automatically before and completes automatically afterward.

Promise Wrapper Example

import { withProgress } from "react-top-progress";

const data = await withProgress(fetch("/api/users"));

Component Properties

You can customize <TopProgress /> passing any of the following props:

PropertyTypeDefaultDescription
progressnumberHardset the progress (0-100) if you want to bypass the internal store and control state yourself.
colorstring"#29D"Background color of the bar. Accepts linear-gradient(...) or hex codes.
heightnumber3Height of the progress bar in pixels.
shadowbooleantrueAppends a glorious trailing drop-glow peg matching the bar's color tracking its head.
backgroundstring"transparent"Fills the container div's background layer under the progress element.
transitionSpeednumber200Fade transition time (ms) for the fade-out completion sequence.
loaderSpeednumber500Loader width transition speed (ms).
waitingTimenumber1000The delay time (ms) loader waits at 100% width before fading entirely out.
easingstring"cubic-bezier(0.4, 0, 0.2, 1)"Customizable CSS animation timing path curve.
styleCSSPropertiesInject custom JSX styles directly onto the loader element.
classNamestringApply a specific custom CSS class to the loader element.
containerStyleCSSPropertiesConfigure inline styles for the fixed <div /> wrapper container.
containerClassNamestringCustom CSS class applied onto the wrapper container.
onLoaderFinished() => voidA callback function executing precisely when the loader fully hits 100% max width.

Compared to Alternatives

Developers need to know why to switch. Here is the breakdown:

LibraryDependenciesSSR SafeRouting BindingsPromise WrapBundle Size
nprogressOld jQuery style logicNoLarger
nextjs-toploaderNext-specific onlyYes✅ (Next.js)Medium
react-top-loading-barReact mostlySomeMedium
react-top-progress0 dependenciesYes✅ (Agnostic)Tiny (~1.9kb)

Credits

Designed for the modern web. Inspired by the classic nprogress and Next.js' nextjs-toploader. Ideal when you need explicit control without relying solely on framework routing events.

Built with ❤️ by Harry Mate. 🌟 If you find this library helpful, consider dropping a Star on GitHub and following me (@harrymate22) for more open-source tools!

License

MIT © harrymate22

Keywords

react

FAQs

Package last updated on 28 Feb 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts