revalidate in Next.js getStaticProps?getStaticProps with revalidate: 10. What is the behavior of the page after deployment?export async function getStaticProps() { return { props: { time: Date.now() }, revalidate: 10 }; } export default function Page({ time }) { return <p>Time: {time}</p>; }
With revalidate: 10, Next.js serves the static page and regenerates it in the background at most once every 10 seconds when a request comes in. It does not regenerate on every request or on a fixed timer.
revalidate for automatic page updates?revalidate option for Incremental Static Regeneration.getStaticProps supports revalidate to enable Incremental Static Regeneration. getServerSideProps runs on every request and does not use revalidate.
revalidate not update after 10 seconds?revalidate: 10 in getStaticProps but the page content never updates after deployment. What is the most likely cause?export async function getStaticProps() { const data = await fetch('https://api.example.com/data').then(res => res.json()); return { props: { data }, revalidate: 10 }; } export default function Page({ data }) { return <pre>{JSON.stringify(data)}</pre>; }
If the API data does not change, the regenerated page will look the same, so it appears not to update. The revalidate option is correctly used as a number.
Next.js serves the existing static page to all requests while regenerating the page once in the background to avoid delays or errors.
revalidate and dynamic data?export async function getStaticProps() { return { props: { timestamp: Date.now() }, revalidate: 10 }; } export default function Page({ timestamp }) { return <p>Timestamp: {timestamp}</p>; }
The first request serves the static page with the initial timestamp. After 10 seconds, the next request triggers regeneration, so the second request shows an updated timestamp.