Overview

nprogress-next is a drop-in replacement for NProgress 0.2.0. Most apps can migrate by changing the import only.

✅ Zero-code migration for most apps

// Before
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

// After
import NProgress from 'nprogress-next'
import 'nprogress-next/styles.css' // optional — auto-injected by default

API Mapping

NProgress 0.2.0nprogress-nextNotes
import NProgress from 'nprogress'import NProgress from 'nprogress-next'Same singleton API
require('nprogress')require('nprogress-next')Returns singleton (CJS interop fixed)
NProgress.configure({...})SameAll options supported
NProgress.start()Same—
NProgress.done()Same—
NProgress.set(0.5)Same—
NProgress.inc()SameUses 0.2.0 probabilistic formula
NProgress.trickle()SameNow inc(trickleRate) internally
NProgress.promise(p)SameConcurrency semantics identical
NProgress.remove()Same—
NProgress.statusSame (now writable)NProgress.status = null works
NProgress.settingsSame (mutable)Module-level object
NProgress.versionSame'0.1.0' etc.
NProgress.getPositioningCSS()SameReturns CSS string
import 'nprogress/nprogress.css'import 'nprogress-next/styles.css' OR auto-injectedCSS variables: --np-*
new NProgress()import { createProgress } from 'nprogress-next'Named export, not constructor
—NProgress.subscribe(fn)New — reactive updates
—prefers-reduced-motion respectedNew — automatic
—SSR-safeNew — no window access on import
—--np-color, --np-height, --np-zNew — CSS variable theming

Breaking Changes (Minimal)

Common Patterns

Ajax Loading

// Before (jQuery)
$(document).ajaxStart(() => NProgress.start())
$(document).ajaxStop(() => NProgress.done())

// After (fetch + nprogress-next)
const originalFetch = window.fetch
window.fetch = async (...args) => {
  NProgress.start()
  try {
    return await originalFetch(...args)
  } finally {
    NProgress.done()
  }
}

Router Integration

// React Router v6
import { useProgress } from 'nprogress-next-react'
import { useLocation } from 'react-router-dom'

export function ProgressWrapper() {
  const { start, done } = useProgress()
  const location = useLocation()

  useEffect(() => {
    start()
    const timer = setTimeout(done, 300) // minimum visible time
    return () => clearTimeout(timer)
  }, [location.pathname])

  return null
}

Custom Template

// NProgress 0.2.0 template still works
NProgress.configure({
  template: '<div class="bar"><div class="peg"></div></div><div class="spinner"></div>'
})

// nprogress-next also accepts .bar / .spinner classes
NProgress.configure({
  barSelector: '.bar',
  spinnerSelector: '.spinner'
})

TypeScript

Types are included — no @types/nprogress needed. If you had declare module 'nprogress', update to 'nprogress-next'.