Using next-payload, how to revalidate?

default discord avatar
last month

Hey there, new to Payload and never used NextJS for anything crazy, but I am trying to use the next-payload utility to integrate payload with a new nextJS app (just a small business site for a new company) and am having trouble figuring out how to revalidate pages and a global header so the updated content in the CMS shows in the frontend after deploying things to Vercel.

I've been able to output pages and the nav items from the global header in the frontend, but after updating content in the CMS and saving and visiting the frontend, the old content shows. This is due to the pages being statically generated when deployed to Vercel, but how would I go about setting up revalidation so the updates show in the frontend? I've looked at the payload website template code that's output after using create-payload-app, and I'm seeing a src/app/api/revalidate file which seems to handle things for the website template, but I'm not seeing any revalidate code on the nextjs side via next-payload even though there is src/pages/api code that next-payload adds.

Also, I'm using the local API in the app folder to display the initial content that shows before updates in the CMS are made. Is this right? Should I be using fetch instead in order for revalidate to work? Happy to provide any code needed!

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!


Connect with the Payload Community on Discord



Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.