Installation

pnpm add nprogress-next-vue
# peer: vue ^3.3

Plugin (Global Registration)

import { createApp } from 'vue'
import { NProgressNext } from 'nprogress-next-vue'
import 'nprogress-next-vue/styles.css' // optional

const app = createApp(App)
app.use(NProgressNext) // registers <ProgressBar /> globally
app.mount('#app')

Components

<ProgressBar />

<script setup lang="ts">
import { ProgressBar, useProgress } from 'nprogress-next-vue'

const { status } = useProgress()
</script>

<template>
  <ProgressBar :progress="status ?? 0" color="#29d" />
  <button @click="start">Start</button>
</template>
PropTypeDefaultDescription
progressnumber0Progress value 0..1 (clamped)
visiblebooleantrueRender nothing when false
spinnerbooleantrueShow/hide spinner
labelstring | null'Loading'aria-label (null omits)
speednumber200Transition duration (ms)
easingstring'linear'CSS easing
heightstring'2px'Sets --np-height
colorstring'#29d'Sets --np-color
zIndexnumber | string1031Sets --np-z
classstring—Additional class
styleCSSProperties—Additional inline styles

useProgress(options?)

Composable that creates a core instance and returns reactive state. Uses shallowRef + watch + onScopeDispose for proper cleanup.

import { useProgress } from 'nprogress-next-vue'

export default {
  setup() {
    const { progress, status, isStarted, isRendered, start, done, set, inc } = useProgress({
      minimum: 0.1,
      trickle: true
    })

    return { status, start, done }
  }
}
ReturnTypeDescription
progressProgressInstanceCore instance
statusRef<number | null>Reactive progress
isStartedComputedRef<boolean>Reactive started state
isRenderedComputedRef<boolean>Reactive rendered state
start()voidStart progress
done(force?)voidComplete progress
set(n)voidSet progress
inc(amount?)voidIncrement

Complete Example

<script setup lang="ts">
import { ProgressBar, useProgress } from 'nprogress-next-vue'

const { status, start, done } = useProgress()

const handleFetch = async () => {
  start()
  try {
    await fetch('/api/data')
  } finally {
    done()
  }
}
</script>

<template>
  <ProgressBar :progress="status ?? 0" color="#29d" />
  <button @click="handleFetch" :disabled="status !== null">
    {{ status !== null ? 'Loading...' : 'Fetch Data' }}
  </button>
</template>

Nuxt 3

// plugins/nprogress.ts
import { NProgressNext } from 'nprogress-next-vue'

export default defineNuxtPlugin((nuxtApp) => {
  nuxtApp.vueApp.use(NProgressNext)
})

// In any component
<script setup lang="ts">
import { useProgress } from 'nprogress-next-vue'
const { start, done } = useProgress()
</script>

SSR Notes

Exports

import {
  ProgressBar,      // DefineComponent
  useProgress,      // Composable
  NProgressNext,    // Plugin { install(app) }
  styles,           // Stylesheet string
  createProgress,   // Re-exported from core
  defaultSettings,
  injectStyles,
  NProgress,
  version,
  type ProgressBarProps,
  type UseProgressReturn,
  type ProgressInstance,
  type ProgressOptions,
  type ProgressSettings
} from 'nprogress-next-vue'