Next.js Discord

Discord Forum

revalidatePath on route handler

Unanswered
Eric Burel posted this in #help-forum
Open in Discord
^_ all on the title: is that doable to call "revalidatePath("/api/something")", on Route handler URL rather than a page?
I tried it on 13.4, it doesn't seem to work. The documentation doesn't mention it, and I found no issues. Yet, Route Handlers are being statically built if they don't have explicit dynamic requirement. So, it would probably make sense to be able to invalidate them on demand. But it doesn't seem possible. I am using "export const dynamic = "force-dynamic"" in the meantime

4 Replies

Small bump
Good question… I never thought of this use case before. Does it work if you tag the query using fetch/unstable_cache, and you use revalidateTag?

What you said should work but maybe because it’s not part of the react router it was overlooked. I think if it really can’t work then you might need to open a new issue (or make a new PR :sunglasses_1:)