Next.js Discord

Discord Forum

Loading.tsx Render

Answered
Huntaway posted this in #help-forum
Open in Discord
HuntawayOP
If I put loading.tsx in root will it propagate to all routes or do I need a loading.tsx in every route?
Answered by LuisLl
It’ll depend on how you want the user experience to be. A single loading.tsx at the root of your app will be rendered when any async component (either page or any component) suspends.

For a nicer user experience add loading.tsx to individual pages or individual components (either server or client) so only those suspend. You can use <Suspense> with a fallback to wrap those which aren’t a page directly.

loading.tsx It’s literally a <Suspense> boundary wrapping your page so, have that in mind.. you’re suspending your whole app if you only have one loading.tsx file at the root
View full answer

2 Replies

It’ll depend on how you want the user experience to be. A single loading.tsx at the root of your app will be rendered when any async component (either page or any component) suspends.

For a nicer user experience add loading.tsx to individual pages or individual components (either server or client) so only those suspend. You can use <Suspense> with a fallback to wrap those which aren’t a page directly.

loading.tsx It’s literally a <Suspense> boundary wrapping your page so, have that in mind.. you’re suspending your whole app if you only have one loading.tsx file at the root
Answer
@Huntaway was it useful?