Do I have to place loading.js for every route I have or only on the home route.
Unanswered
Asiatic Lion posted this in #help-forum
Asiatic LionOP
I have loading.js in my home route. When I navigate from other routes It shows for a while the loading spinner then the whole page becomes visible. I want the static content to be loaded instantly and I do have suspense for my async component section. Can't figure out what can lead to this?
7 Replies
@Asiatic Lion I have loading.js in my home route. When I navigate from other routes It shows for a while the loading spinner then the whole page becomes visible. I want the static content to be loaded instantly and I do have suspense for my async component section. Can't figure out what can lead to this?
Can you share a minimal repro repo via jsfiddle or https://codesandbox.io/ ? That would help a lot to understand what you are trying to do and what you want to archive
Asiatic LionOP
@B33fb0n3 Hey, due to NDA can't share the code. But on my app I have a service route, where when I navigate for the first time i.e. (before catch is stored) the navigation is happening but my loading page spinner is showing a long time inspite of the page has all static content with use client. I only have loading.js on my home page route that i.e.
Attaching the network request SS. Please If could help
src
-/app
-/about
-/page.jsx
-/pricing
-/page.jsx
-/service
-/page.jsx
-/page.js
-/layout.js
-/loading.jsAttaching the network request SS. Please If could help
@Asiatic Lion <@301376057326567425> Hey, due to NDA can't share the code. But on my app I have a service route, where when I navigate for the first time i.e. (before catch is stored) the navigation is happening but my loading page spinner is showing a long time inspite of the page has all static content with use client. I only have loading.js on my home page route that i.e.
`src
-/app
-/about
-/page.jsx
-/pricing
-/page.jsx
-/service
-/page.jsx
-/page.js
-/layout.js
-/loading.js`
Attaching the network request SS. Please If could help
thanks for sharing. I understand, that you can't share any details from the code itself. Right now I am still not able to provide you the help, that you need, because I don't see any code. Please create a reproduction repo. DONT share details included inside your NDA. You can share: the file structure and replace text inside it
@Asiatic Lion <@301376057326567425> Hey, due to NDA can't share the code. But on my app I have a service route, where when I navigate for the first time i.e. (before catch is stored) the navigation is happening but my loading page spinner is showing a long time inspite of the page has all static content with use client. I only have loading.js on my home page route that i.e.
`src
-/app
-/about
-/page.jsx
-/pricing
-/page.jsx
-/service
-/page.jsx
-/page.js
-/layout.js
-/loading.js`
Attaching the network request SS. Please If could help
When loading starts, nextjs will look for the suspense boundary(this is created by loading.tsx), once this loading boundary is used up, it wont be hit again till the next reload. Meaning it wont show up for components or pages inside the layout (if the layout trigged the suspense boundary) or even parallel routes if im correct.
To make it show for them you either have to explicitly define a suspense boundary(for components for example) or put a loading.tsx (for pages inside a layout)
To make it show for them you either have to explicitly define a suspense boundary(for components for example) or put a loading.tsx (for pages inside a layout)
1) Loading starts for layout (/loading.tsx HIT)
2) Actual page route inside the layout starts loading (/page/loading.tsx HIT)(This is what i can remember from my own experience, maybe a bit wrong)