How to use revalidatePath
Answered
Common Rosefinch posted this in #help-forum
Common RosefinchOP
How can I update the content of a page after a mutation? Is this what "revalidatePath" is intended for?
Please need your help!
Please need your help!
8 Replies
reavalidatePath works if you have a statically cached route and you want to invalidate its build cache
how did you update the content of a page?
and how are the content of a page rendered? dynamically or statically? look for the symbols when building the application.
Common RosefinchOP
@aardani
I have a /blogs/[slug] page statically rendered using generateStaticParams and the page has a comments section. the updating happens when a user types in a comment and hit send, I call a POST /posts/comment API endpoint to save the post. the intent here is to refresh the /blogs/[slug] page to update stuff like comments count
I have a /blogs/[slug] page statically rendered using generateStaticParams and the page has a comments section. the updating happens when a user types in a comment and hit send, I call a POST /posts/comment API endpoint to save the post. the intent here is to refresh the /blogs/[slug] page to update stuff like comments count
you can use revalidatePath to trigger an on-demand revalidation
Answer
when the page is next requested, it will rebuild the page again
hence allowing ISR in your app
Check out the docs for how to reavlidate the
/blogs page as well as the slug page