Next.js Discord

Discord Forum

How to call revalidatePath outside the context of a Next.js app?

Unanswered
Chub mackerel posted this in #help-forum
Open in Discord
Chub mackerelOP
I have a Node.js app that makes changes to my database (running on Trigger.dev).
I want to revalidate pages after these changes are made. But because it's outside of Next.js context it fails with
Invariant: static generation store missing in revalidatePath

What's the best way to handle this?

3 Replies

Hi Elie! The pattern I've seen the most is to use an api route for that

A /api/revalidate protected that can take a custom path to revalidate

I don't know if this is the best way to handle it though
That’s the only way actually. revalidatePath needs to be run inside route handlers or server actions. It doesn’t work anywhere else.
Chub mackerelOP
Thanks. That's what I thought of doing. Will do that 🙏