0
0
NextJSframework~20 mins

Revalidation patterns in NextJS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Next.js Revalidation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
What happens when using revalidate in Next.js getStaticProps?
Consider a Next.js page using getStaticProps with revalidate: 10. What is the behavior of the page after deployment?
NextJS
export async function getStaticProps() {
  return {
    props: { time: Date.now() },
    revalidate: 10
  };
}

export default function Page({ time }) {
  return <p>Time: {time}</p>;
}
AThe page is statically generated once and never updated.
BThe page is regenerated at most once every 10 seconds when requested.
CThe page is regenerated on every request, ignoring the 10 seconds.
DThe page is regenerated exactly every 10 seconds regardless of requests.
Attempts:
2 left
💡 Hint
Think about how Next.js handles Incremental Static Regeneration with revalidate.
📝 Syntax
intermediate
1:30remaining
Which Next.js data fetching method supports revalidate for automatic page updates?
Select the Next.js data fetching method that supports the revalidate option for Incremental Static Regeneration.
AgetInitialProps
BgetServerSideProps
CgetStaticProps
DAPI routes
Attempts:
2 left
💡 Hint
Only one method generates static pages with revalidation.
🔧 Debug
advanced
2:30remaining
Why does a Next.js page with revalidate not update after 10 seconds?
A developer sets revalidate: 10 in getStaticProps but the page content never updates after deployment. What is the most likely cause?
NextJS
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>;
}
AThe API response is cached and does not change, so the page looks static.
BThe page needs a manual rebuild to update content despite revalidate.
CThe <code>revalidate</code> option must be a string, not a number.
DThe <code>getStaticProps</code> function is missing a <code>fetch</code> call.
Attempts:
2 left
💡 Hint
Consider what happens if the data source does not change.
🧠 Conceptual
advanced
2:00remaining
How does Next.js handle concurrent requests during page revalidation?
When multiple users request a page that is due for revalidation, how does Next.js handle regenerating the page?
ANext.js serves the old page to all requests and regenerates the page once in the background.
BNext.js returns an error to all requests during regeneration.
CNext.js blocks all requests until the page is regenerated.
DNext.js regenerates the page multiple times concurrently for each request.
Attempts:
2 left
💡 Hint
Think about user experience during regeneration.
state_output
expert
3:00remaining
What is the output of this Next.js page with revalidate and dynamic data?
Given the code below, what will the page display if requested twice with a 15-second gap?
NextJS
export async function getStaticProps() {
  return {
    props: { timestamp: Date.now() },
    revalidate: 10
  };
}

export default function Page({ timestamp }) {
  return <p>Timestamp: {timestamp}</p>;
}
AThe page throws an error because Date.now() is used in getStaticProps.
BBoth requests show the same timestamp from the first build.
CBoth requests show the current time at request, ignoring revalidate.
DThe first request shows the initial timestamp; the second shows a new timestamp updated after 10 seconds.
Attempts:
2 left
💡 Hint
Remember how revalidate controls regeneration timing.