Next.js Discord

Discord Forum

Loading event while page changes

Answered
Dwarf Crocodile posted this in #help-forum
Open in Discord
Dwarf CrocodileOP
In previous version, while the page starts changing we can get that event using router.events, but in nextjs 14 app router, there is no router event. How to handle the loading while page changes in nextjs 14 app router.
Answered by B33fb0n3
that's also possible when using for example Nextjs-toploader. You can find that package here: https://www.npmjs.com/package/nextjs-toploader
View full answer

6 Replies

@Dwarf Crocodile In previous version, while the page starts changing we can get that event using router.events, but in nextjs 14 app router, there is no router event. How to handle the loading while page changes in nextjs 14 app router.
you can add a loading.tsx inside your route, to display a instant loading page to the user. After the page finished loading, the actual page will be displayed. In the future there are plans on PPR
Dwarf CrocodileOP
loading.tsx works after the page loads. But I want to show the loader when the page loads starts.
@Dwarf Crocodile **loading.tsx** works after the page loads. But I want to show the loader when the page loads starts.
that's also possible when using for example Nextjs-toploader. You can find that package here: https://www.npmjs.com/package/nextjs-toploader
Answer
Dwarf CrocodileOP
Thanks, its working.
@Dwarf Crocodile Thanks, its working.
Happy to help. Please mark solution
that's not the solution