Menu

Replacing NProgress in Vue 3 and Nuxt
📰

Replacing NProgress in Vue 3 and Nuxt

DEV Community: vue·Navid jaberi·1 day ago
#jV574QhC
#devtovue#devto#dev#nprogress#done
Reading 0:00
15s threshold

NProgress gets almost 5 million downloads a week. Its last release, 0.2.0, came out in May 2015, and it doesn't ship TypeScript types, so another 1.5 million downloads a week go to @types/nprogress . It still works, and in a Vue 3 app it usually looks like this:

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

router . beforeEach ( ( ) => { NProgress . start ( ) } ) router . afterEach ( ( ) => { NProgress . done ( ) } )

Enter fullscreen mode

Exit fullscreen mode

That setup has two problems you've probably seen without naming them.

Problem 1: it flashes on fast navigations

start() shows the bar right away. When the next route is already loaded, or its data comes from cache, the navigation takes 30ms and the user sees a thin line blink at the top of the page. That blink makes a fast app look slow.

Problem 2: parallel requests end it too early

People also call NProgress around their own requests:

async function load ( url : string ) { NProgress .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.