Skip to content

Step 4 - Loaders in Next

Course: NextJS (Server side) - chapter 4

What if the getUserDetails call takes 5s to finish (lets say the backend is slow). You should show the user a loader during this time

Just like page.tsx and layout.tsx , you can define a skeleton.tsx file that will render until all the async operations finish

  1. Create a loading.tsx file in the root folder
  2. Add a custom loader inside
export default function Loading() {
return <div className="flex flex-col justify-center h-screen">
<div className="flex justify-center">
Loading...
</div>
</div>
}