NextTopLoader
NextTopLoader is a simple and customizable loading bar component for Next.js applications. It provides visual feedback to users during page transitions and data loading.
Installation
Install the package using npm or yarn:
npm install nextjs-toploader
Basic Usage
Add the NextTopLoader component to your root layout:
import NextTopLoader from 'nextjs-toploader';export default function RootLayout({ children }) {return (<html><body><NextTopLoadercolor="hsl(var(--foreground))"initialPosition={0.08}crawlSpeed={200}height={3}crawl={true}showSpinner={true}easing="ease"speed={200}shadow="0 0 10px #2299DD,0 0 5px #2299DD"/>{children}</body></html>);}
Props
Prop
Type
Default
Description
colorstring—
Color of the loading bar
heightnumber—
Height of the loading bar in pixels
showSpinnerboolean—
Show or hide the loading spinner
crawlboolean—
Enable or disable the crawling animation
speednumber—
Animation speed in milliseconds