A lightweight page loader for Next.js to give your users subtle feedback on navigating through your pages.
npm i next-page-loader
In your _app.tsx
import and use the page loader component like so:
import type { AppProps } from 'next/app';
import PageLoader from 'next-page-loader';
function MyApp({ Component, pageProps }: AppProps) {
return (
<>
<PageLoader />
<Component {...pageProps} />
</>
);
}
export default MyApp;
For the basis setup this is about it. A loading progress indicator will be shown on switching routes.
- Easy to use
- Lightweight (~2kb)
- Typescript support
- Customization (Tailwind.css compatible)
The page loader component container and progress bar styling can be fully customized through class or style object props.
<PageLoader style={{ backgroundColor: 'orange', height: '5px' }} />
<PageLoader className="h-[3px] bg-orange-500 shadow-lg shadow-orange-500/50 w-full" />
There is also a full Next.js + Tailwind.css example
- Run
nvm i
to use the correct node version - Run
npm i
to install dependencies - Configure and use prettier
- Run
npm run dev
to run dev server and watch changes