using app router hooks on pages router
Unanswered
Cape lion posted this in #help-forum
Cape lionOP
Is it safe to use the "app router" hooks (e.g.
my question is mostly because it would make it easier to migrate those pages to the app router when the time comes
usePathname from next/navigation, etc) on a "page router" page? I was expecting it to fail, but seems like it still works (I'm still afraid there might be some weird side effects)my question is mostly because it would make it easier to migrate those pages to the app router when the time comes
4 Replies
Western paper wasp
The docs for usePathname make a couple specific references to its behavior under the
pages routerwhich implies it’s intentionally supported under
pagesthey stop short of stating direcltly that
usePathname will work under the pages routerbut i’d say it’s a reasonably safe bet that it will work as you expect under
pages