Prerequisites
- Next.js application with version 11 or higher
Getting started
Firstly, we must install the NProgress
npm module
And its types
Usage
Importing styles
Custom app
If you do not have an _app file yet, you can copy this template below. This example comes from Next.js' docs.
Open template
To use the module, open your _app.tsx
file. We must import the required styles from
nprogress.
Router events
We'll add a useEffect
in our component and add 2 handlers to handle routeChangeStart
and routeChangeComplete
.
More info about router events.
Done
That's it! Start your dev server and see the changes!
Examples