0
0
NextJSframework~20 mins

Static rendering (default) in NextJS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Next.js Static Rendering Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
What is the output of this Next.js static page?
Consider this Next.js component using default static rendering. What will the user see when visiting the page?
NextJS
export default function Home() {
  return <h1>Welcome to Next.js!</h1>;
}
AThe page shows a heading: 'Welcome to Next.js!' immediately on load.
BThe page shows a loading spinner before the heading appears.
CThe page shows an error because no data fetching method is used.
DThe page content is empty because static rendering requires getStaticProps.
Attempts:
2 left
💡 Hint
Static rendering means the page is pre-built and served as is.
state_output
intermediate
2:00remaining
What happens to state in a statically rendered Next.js page?
Given this component, what will be the initial displayed count when the page loads?
NextJS
import { useState } from 'react';

export default function Counter() {
  const [count, setCount] = useState(5);
  return <p>Count: {count}</p>;
}
AThe page shows 'Count: 5' immediately on load.
BThe page shows 'Count: 0' because static rendering resets state.
CThe page shows 'Count: 5' but only after a client-side update.
DThe page shows nothing because useState is not supported in static pages.
Attempts:
2 left
💡 Hint
State initializes on the client after static HTML is loaded.
📝 Syntax
advanced
2:30remaining
Which code snippet correctly uses static rendering with data fetching?
Select the code that correctly fetches data at build time for static rendering in Next.js.
A
export async function getServerSideProps() {
  const res = await fetch('https://api.example.com/data');
  const data = await res.json();
  return { props: { data } };
}

export default function Page({ data }) {
  return &lt;div&gt;{data.title}&lt;/div&gt;;
}
B
export default async function Page() {
  const res = await fetch('https://api.example.com/data');
  const data = await res.json();
  return &lt;div&gt;{data.title}&lt;/div&gt;;
}
C
export async function getStaticProps() {
  const res = await fetch('https://api.example.com/data');
  const data = await res.json();
  return { props: { data } };
}

export default function Page({ data }) {
  return &lt;div&gt;{data.title}&lt;/div&gt;;
}
D
export default function Page() {
  const data = fetch('https://api.example.com/data').then(res =&gt; res.json());
  return &lt;div&gt;{data.title}&lt;/div&gt;;
}
Attempts:
2 left
💡 Hint
Static rendering with data requires getStaticProps function.
🔧 Debug
advanced
2:30remaining
Why does this statically rendered page show stale data?
This Next.js page uses getStaticProps to fetch data. After deployment, the data changes on the server but the page still shows old data. Why?
NextJS
export async function getStaticProps() {
  const res = await fetch('https://api.example.com/data');
  const data = await res.json();
  return { props: { data } };
}

export default function Page({ data }) {
  return <div>{data.title}</div>;
}
ABecause the fetch URL is incorrect and returns cached data.
BBecause getStaticProps runs on every request, but the API is caching old data.
CBecause the component is missing useEffect to update data on the client.
DBecause static rendering builds the page once at build time and does not update until redeployed.
Attempts:
2 left
💡 Hint
Static pages do not update automatically after build.
🧠 Conceptual
expert
3:00remaining
Which statement best describes Next.js static rendering behavior?
Choose the most accurate description of how Next.js static rendering works by default.
ANext.js renders pages on the server for every request, then caches the HTML for future requests.
BNext.js pre-renders pages at build time into static HTML, which is served instantly without server code on each request.
CNext.js renders pages entirely on the client after loading a minimal HTML shell from the server.
DNext.js requires explicit server-side code to generate static HTML for each page on demand.
Attempts:
2 left
💡 Hint
Think about what 'static' means in web pages.