logo image
  • Build progress docs

    • Start NextJs project
    • Install linting and formatting (optional)

    • Setup Mongo DB
    • Setup authentication

    • Setup dark mode
    • Multiple languages
    • Setup online payment

    • Setup live chat
    • Setup Top Progress Loader
  • Other tech docs

    • Useful commands in Yarn
    • Basic Git tutorial
    • Basic Gitlab
    • Install WSL in Window
    • Testing - Jest testing library
    • Tools

    • Using icons in NextJs
    • Setup environment variables
    • Basic of Moongoose, MongDB
    • Unitest in Next.js
    • NVM - Node version management
    • Write CI/CD Gitlab for Next.js
    • Setup Messenger live chat for Next.js/React.js
  1. Home
  2. Build Progress Docs
  3. Top Loader

Enhance Your Next.js App with a Smooth Top Loader

Add a sleek, animated progress bar to your Next.js app to improve user experience during page transitions. Follow this simple guide to set it up in just minutes!


Install lib

We will use nextjs-toploader to handle top progress loader:

bash
yarn add nextjs-toploader or npm install nextjs-toploader

Integrate Top Loader into the Next.js App

Create a file app/provider.tsx

jsx
"use client"; import React from "react"; import NextTopLoader from "nextjs-toploader"; const Providers = ({ children }: { children: React.ReactNode }) => { return ( <> <NextTopLoader color="#ffbe59" /> {children} </> ); }; export default Providers;

Notes: You can change the color which you want in the color prop.

App Provider component to root of layout app/layout.tsx (put it inside the body tag)

jsx
<html lang="en" className={clsx("h-full scroll-smooth bg-white antialiased", inter.variable, lexend.variable)} > <body className="flex h-full flex-col"> <Providers> {children} </Providers> </body> </html>

Now every time you click on the link on the Next.js project, the Top Progress Bar will be loading, it will inform for user that the website is loading, so it will improve the user experience.

Previous
Setup live chat
Next
Useful commands in Yarn

On this page

  1. Install lib

  2. Integrate Top Loader into the Next.js App