detect page change
Unanswered
Maine Coon posted this in #help-forum
Maine CoonOP
Hey, I need to make a custom loader that only dissapears the page when the page has loaded & it connected to the websocket:
my idea was to use router.events setLoading(ture) and in the actual page in the websocket connected event setLoading(false) but they're not available in app router.
I'm new to nextjs any ideas how I can do this in app router?
my idea was to use router.events setLoading(ture) and in the actual page in the websocket connected event setLoading(false) but they're not available in app router.
I'm new to nextjs any ideas how I can do this in app router?
10 Replies
I'd use a
You can use it on client component
useState, and once loaded, setLoading(false).You can use it on client component
@"use php" I'd use a `useState`, and once loaded, `setLoading(false)`.
You can use it on client component
Maine CoonOP
How do I know when the page change was initiated tho?
@Maine Coon Hey, I need to make a custom loader that only dissapears the page when the page has loaded & it connected to the websocket:
my idea was to use router.events setLoading(ture) and in the actual page in the websocket connected event setLoading(false) but they're not available in app router.
I'm new to nextjs any ideas how I can do this in app router?
You’ve not specified about page change here
@"use php" You’ve not specified about page change here
Maine CoonOP
The title of the post is detect page change
@Maine Coon The title of the post is detect page change
You can create a route group for those 2 pages, with a client layout and use useRouter to detect
Maine CoonOP
useRouter only rerenders when the page change was finished, not when it was initiated
I need a way to detect via code when a page change was initiated