VuePress plugin that integrates NProgress to display a progress bar during page navigation and loading
npx @tessl/cli install tessl/npm-vuepress--plugin-nprogress@1.9.0The VuePress NProgress Plugin integrates NProgress, a JavaScript progress bar library, to provide visual feedback during page navigation and loading in VuePress documentation sites. It automatically displays a slim progress bar at the top of the page during route transitions, enhancing user experience by providing visual feedback when content is being loaded.
npm install @vuepress/plugin-nprogressAs a VuePress plugin, this package is typically used through VuePress configuration rather than direct imports:
// .vuepress/config.js
module.exports = {
plugins: [
'@vuepress/plugin-nprogress'
]
}Direct plugin object access (for plugin development):
const nprogressPlugin = require('@vuepress/plugin-nprogress');Client-side code uses ES6 modules:
import Vue from 'vue';
import nprogress from 'nprogress';Install the plugin in your VuePress site configuration:
// .vuepress/config.js
module.exports = {
plugins: [
'@vuepress/plugin-nprogress'
]
}The plugin will automatically:
// .vuepress/config.js
module.exports = {
plugins: {
'@vuepress/plugin-nprogress': {}
}
}The main plugin export that defines VuePress plugin configuration.
/**
* VuePress plugin configuration object
* @type {import('@vuepress/types').Plugin}
*/
module.exports = {
clientRootMixin: string;
enhanceAppFiles: string;
}The plugin configuration provides:
clientRootMixin: Path to Vue mixin that handles router integrationenhanceAppFiles: Path to file that imports necessary stylesheetsThe plugin includes a Vue mixin that automatically integrates with VuePress router:
/**
* Vue mixin for NProgress integration
* Automatically mounted when VuePress loads
*/
export default {
mounted() {
// Configure NProgress and set up router hooks
// Sets showSpinner: false and integrates with Vue Router
}
}!Vue.component(to.name) check to avoid showing progress for cached componentsThe plugin includes custom Stylus styling that integrates with VuePress theming:
// Progress bar styling variables
$nprogressColor ?= $accentColor
// Progress bar elements
#nprogress
pointer-events none
.bar
background $nprogressColor
position fixed
z-index 1031
top 0
left 0
width 100%
height 2px
.peg
display block
position absolute
right 0px
width 100px
height 100%
box-shadow 0 0 10px $nprogressColor, 0 0 5px $nprogressColor
opacity 1.0
transform rotate(3deg) translate(0px, -4px)
.spinner
display block
position fixed
z-index 1031
top 15px
right 15px$accentColor for progress bar colorThe plugin follows VuePress plugin architecture patterns:
index.js exports plugin configuration objectclientRootMixin to integrate with Vue app lifecycleenhanceAppFiles to include necessary stylesheetsbeforeEach and afterEach hooks for navigation trackingPlugin interface from @vuepress/typesclientRootMixin and enhanceAppFiles configuration options$router.beforeEach for navigation start detection$router.afterEach for navigation completionnprogress.configure({ showSpinner: false }) for initializationnprogress.start() when navigation beginsnprogress.done() when navigation completes