We created a WP plugin (Next.js Revalidate) to purge & re-build the cached pages from the WordPress admin area.
It also automatically purges & re-builds when a page/post/... is saved or updated.
Based on the Next.js On-demand revalidation documentation
The revalidation request will be sent to the configured URL endpoint with two query arguments :
- The relative
path
to revalidate - The
secret
to protect the revalidation endpoint.
https://example.com/api/revalidate?path=/hello-world/&secret=my-secret-string
To configure this plugin here are the steps to follow :
- Activate Next.js Revalidate plugin in the WP Admin
- In Settings > Next.js revalidate (on WP Admin) set the different settings :
- Revalidate url => https://example.com/api/revalidate
- Revalidate Secret => you can use https://www.uuidgenerator.net/ to generate one
- Set the
REVALIDATE_SECRET
environment variable to that same Revalidate Secret on Next.js server.
Note: It's important to note that the revalidation doesn't work if you run the project on your local.