0
0
NextJSframework~20 mins

ISR (Incremental Static Regeneration) in NextJS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
ISR Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
What happens when a Next.js page uses ISR with revalidate set to 10?

Consider a Next.js page that uses getStaticProps with revalidate: 10. What is the behavior of this page after deployment?

NextJS
export async function getStaticProps() {
  // fetch data
  return {
    props: { time: Date.now() },
    revalidate: 10
  };
}

export default function Page({ time }) {
  return <div>Time: {time}</div>;
}
AThe page is regenerated on the client side every 10 seconds after the page loads.
BThe page is regenerated on every request, ignoring the static generation.
CThe page is statically generated at build time and then regenerated on the server at most every 10 seconds when a request comes in.
DThe page is generated only once at build time and never updated until the next build.
Attempts:
2 left
💡 Hint

Think about how Next.js updates static pages with ISR.

📝 Syntax
intermediate
2:00remaining
Which code snippet correctly implements ISR in Next.js?

Choose the code snippet that correctly sets up ISR with a 60-second revalidation interval.

A
export async function getStaticProps() {
  return { props: {}, revalidate: 60 };
}
B
export async function getStaticProps() {
  return { props: {}, revalidate: '60' };
}
C
export async function getStaticProps() {
  return { props: {}, revalidate: true };
}
D
export async function getStaticProps() {
  return { props: {}, revalidate: null };
}
Attempts:
2 left
💡 Hint

Check the type of the revalidate value.

state_output
advanced
2:00remaining
What is the rendered output after ISR page regenerates?

Given this ISR page that shows the current timestamp, what will a user see after the page regenerates?

NextJS
export async function getStaticProps() {
  return {
    props: { timestamp: Date.now() },
    revalidate: 5
  };
}

export default function TimestampPage({ timestamp }) {
  return <div>Timestamp: {timestamp}</div>;
}
AThe page shows the current timestamp on every request, updating live.
BThe page shows a loading spinner while regenerating, then updates automatically on the client.
CThe page shows the timestamp from build time only, never updating.
DThe page shows the timestamp from the last regeneration, updated at most every 5 seconds.
Attempts:
2 left
💡 Hint

Remember ISR regenerates pages on the server, not on the client.

🔧 Debug
advanced
2:00remaining
Why does this ISR page fail to regenerate?

This Next.js page uses ISR but never updates after deployment. What is the likely cause?

NextJS
export async function getStaticProps() {
  const data = await fetch('https://api.example.com/data').then(res => res.json());
  return {
    props: { data },
    revalidate: 0
  };
}

export default function DataPage({ data }) {
  return <div>{data.message}</div>;
}
AThe page needs <code>revalidate</code> set to a negative number to enable ISR.
BSetting <code>revalidate</code> to 0 disables ISR, so the page never regenerates after build.
CThe fetch URL is invalid, causing the regeneration to fail silently.
DThe component must use <code>useEffect</code> to update data for ISR to work.
Attempts:
2 left
💡 Hint

Check the meaning of revalidate: 0 in Next.js ISR.

🧠 Conceptual
expert
3:00remaining
How does ISR improve user experience compared to SSR in Next.js?

Choose the best explanation of how Incremental Static Regeneration (ISR) benefits users compared to Server-Side Rendering (SSR).

AISR serves fast static pages initially and updates them in the background, reducing server load and improving response times compared to SSR which renders on every request.
BISR renders pages on every request like SSR but caches them on the client for faster reloads.
CISR requires manual rebuilds to update pages, so it is slower than SSR but uses less bandwidth.
DISR disables caching and forces the browser to fetch fresh data every time, unlike SSR which caches pages.
Attempts:
2 left
💡 Hint

Think about how ISR combines static and dynamic rendering benefits.