How to revalidate a pages router path from an app router handler?
Answered
Spectacled Caiman posted this in #help-forum
Spectacled CaimanOP
I have a large application that I'm migrating from pages router to app router. Since I'm mid-migration, I have an app router route handler that needs to invalidate a pages router ISR page. Previously I was doing this with something like
Is it possible to trigger a pages router ISR revalidation from an app router route handler?
response.revalidate('/articles')
. The app router now seems to use the revalidatePath
function from next/cache
. However, the docs on this function aren't clear on whether it's able to invalidate a pages router ISR page, and I have not been able to get it to do so.Is it possible to trigger a pages router ISR revalidation from an app router route handler?
Answered by Irish Red and White Setter
I can confirm that
revalidatePath
is unable to revalidate pages that are rendered from /pages
routes.9 Replies
Not that I know of unfortunately.... You could make an endpoint in the pages router to hit to trigger the revalidation... or wait till you move all the necessary stuff over before pushing it to production
Irish Red and White Setter
I wish I knew this too.
We are having huge issues with revalidation. Was on Next v12.
Then we spent a lot of time updating to Next v14.
Now instead, the call can intermittently fail but the failure is that execution simply halts when trying to revalidate these pages.
Restarting node solves the issue, and it's not related to specific pages, any page can be the culprit.
Moving to Next 14 made it worse basically.
We are considering another gamble to update to app router style revalidation but that's another huge rewrite.
NextJS unfortunately is a black box when it comes to stuff like this and it's an awful development experience.
We are having huge issues with revalidation. Was on Next v12.
res.revalidate
led to timeouts after 5 minutes with no explanation for specific url:s.Then we spent a lot of time updating to Next v14.
Now instead, the call can intermittently fail but the failure is that execution simply halts when trying to revalidate these pages.
Restarting node solves the issue, and it's not related to specific pages, any page can be the culprit.
Moving to Next 14 made it worse basically.
We are considering another gamble to update to app router style revalidation but that's another huge rewrite.
NextJS unfortunately is a black box when it comes to stuff like this and it's an awful development experience.
Irish Red and White Setter
I can confirm that
revalidatePath
is unable to revalidate pages that are rendered from /pages
routes.Answer
nope, we can't @Spectacled Caiman
Spectacled CaimanOP
NextJS unfortunately is a black box when it comes to stuff like this and it's an awful development experience.

Thanks all for the responses!
@Spectacled Caiman > NextJS unfortunately is a black box when it comes to stuff like this and it's an awful development experience.
<:1000:770004266630774815>
Spectacled CaimanOP
I think this is largely a documentation issue. Next's docs have always been very shallow. They teach you how to use the framework if you stay in the happy path. They don't teach you how the framework actually works, and they don't describe framework behavior specifically enough for developers to understand what edge cases exist. I agree that it's incredibly frustrating.
I feel like I submit feedback on the docs site requesting clarifications almost every time I visit. They never seem to improve much, though.
Irish Red and White Setter
My main problem is that we keep running in to edge cases or intermittent issues, and those are basically impossible to find help with since you can't usually share recreatable issues and report as bugs etc.
Right now we've lost so many hours to chasing the solution to what I mentioned above.
Calls to
Ok, so why?
At this point we're trying to maze through the source code but it's not easy.
Right now we've lost so many hours to chasing the solution to what I mentioned above.
Calls to
res.revalidate
simply stall, nothing happens, it doesn't even try to call getStaticProps
.Ok, so why?
At this point we're trying to maze through the source code but it's not easy.