revalidatePath Error: Invariant: static generation store missing in revalidateTag
Answered
Cimarrón Uruguayo posted this in #help-forum
Cimarrón UruguayoOP
I am trying to use
I am using the app router with the latest next js. Any help is appreciated.
revalidatePath('/dashboard/lending')
at @/lib/actions-lender.ts after doing a completing a POST fetch. But I am getting the error. Error: Invariant: static generation store missing in revalidateTagI am using the app router with the latest next js. Any help is appreciated.
Answered by joulev
in that case you should do ODR the pages router way https://nextjs.org/docs/pages/building-your-application/rendering/incremental-static-regeneration#using-on-demand-revalidation
14 Replies
@Cimarrón Uruguayo I am trying to use `revalidatePath('/dashboard/lending')` at @/lib/actions-lender.ts after doing a completing a POST fetch. But I am getting the error. Error: Invariant: static generation store missing in revalidateTag
I am using the app router with the latest next js. Any help is appreciated.
invariant errors are generally nextjs bug, please make a repro repo and report it to the team at https://github.com/vercel/next.js/issues
Cimarrón UruguayoOP
ok thank you. Is there any other way that I can refresh the page and refresh cache? I tried using router.push but that doesnt seem to refresh cache.
hmm i've been using
revalidatePath
just fine though, that's how you are supposed to refresh the cacheyou can also try
router.refresh()
from a client component in the pageCimarrón UruguayoOP
I feel like i am doing something wrong. CAn you only use revalidatePath in /app directory?
afaik yes, only use it for
app
router pages@joulev you can also try `router.refresh()` from a client component in the page
Cimarrón UruguayoOP
i am on /dashboard/slips/create and once the slip is created, i am redirecting the user to /dashboard/slips using router.push('/dashboard/slips') and revalidatePath('/dashboard/slips') at @/lib/action-slips.ts
@joulev afaik yes, only use it for `app` router pages
Cimarrón UruguayoOP
this probably could be the issue.
@Cimarrón Uruguayo this probably could be the issue.
/dashboard/slips
is a pages router page?Cimarrón UruguayoOP
correct
in that case you should do ODR the pages router way https://nextjs.org/docs/pages/building-your-application/rendering/incremental-static-regeneration#using-on-demand-revalidation
Answer
but still a nextjs bug regardless, report this to the team so they can extend
revalidatePath
to pages router pagesor at least they should've thrown a better error
Cimarrón UruguayoOP
will do, thank you.