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

loading.tsx file
Section titled “loading.tsx file”Just like page.tsx and layout.tsx , you can define a skeleton.tsx file that will render until all the async operations finish
- Create a
loading.tsxfile in the root folder - 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> }