0
0
NextJSframework~20 mins

Static export option in NextJS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Static Export 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 a Next.js page using getStaticProps when statically exported?
Consider a Next.js page that uses getStaticProps to fetch data at build time. What will be the behavior of this page when you run next export to create a static export?
NextJS
export async function getStaticProps() {
  return {
    props: { message: 'Hello from static props!' }
  };
}

export default function Page({ message }) {
  return <div>{message}</div>;
}
AThe page will fetch the message on every request from the server, so it is not fully static.
BThe page will render an empty div because static export ignores <code>getStaticProps</code>.
CThe page will fail to build because <code>getStaticProps</code> is not compatible with static export.
DThe page will render the message at build time and serve a fully static HTML file with the message included.
Attempts:
2 left
💡 Hint
Think about when getStaticProps runs and what next export does.
📝 Syntax
intermediate
2:00remaining
Which option correctly disables server-side rendering for a Next.js page to enable static export?
You want to ensure a Next.js page is fully static and does not use server-side rendering. Which code snippet correctly achieves this for static export?
Aexport const getServerSideProps = async () => ({ props: {} });
Bexport const getStaticProps = async () => ({ props: {} });
Cexport const getInitialProps = async () => ({ props: {} });
Dexport default function Page() { return <div>Static</div>; }
Attempts:
2 left
💡 Hint
Which data fetching method runs at build time?
🔧 Debug
advanced
2:00remaining
Why does next export fail when using getServerSideProps?
You run next export on a Next.js project, but the build fails with an error related to getServerSideProps. Why does this happen?
NextJS
export async function getServerSideProps() {
  return { props: { time: Date.now() } };
}

export default function Page({ time }) {
  return <div>{time}</div>;
}
A<code>getServerSideProps</code> requires a Node.js server at runtime, which <code>next export</code> does not support.
B<code>next export</code> only supports pages without any data fetching methods.
C<code>getServerSideProps</code> is deprecated and cannot be used with Next.js 14+.
D<code>getServerSideProps</code> causes a syntax error during static export.
Attempts:
2 left
💡 Hint
Think about what next export produces and what getServerSideProps needs.
state_output
advanced
2:00remaining
What will be the content of the exported HTML for a page using getStaticProps with dynamic data?
Given this Next.js page, what will the static HTML contain after running next export?
NextJS
export async function getStaticProps() {
  const date = new Date().toISOString();
  return { props: { date } };
}

export default function Page({ date }) {
  return <div>Build time: {date}</div>;
}
AThe HTML will show the exact build time ISO string captured during export.
BThe HTML will show the current time when the user opens the page.
CThe HTML will be empty because dates cannot be serialized in static export.
DThe HTML will show a placeholder text instead of the date.
Attempts:
2 left
💡 Hint
Remember when getStaticProps runs and what data is included in static HTML.
🧠 Conceptual
expert
2:00remaining
Which limitation applies to Next.js static export (next export) compared to server rendering?
Select the correct limitation of using next export for static export in Next.js projects.
AYou cannot deploy static exports to any CDN because they require a Node.js server.
BYou cannot use any React components with hooks because static export only supports class components.
CYou cannot use API routes or server-side code because static export produces only static files.
DYou cannot use CSS modules because static export does not support CSS imports.
Attempts:
2 left
💡 Hint
Think about what static export produces and what features require server runtime.