Next.jsQuestion 04 of 15
getServerSideProps vs getStaticProps — what's the difference?
Answer out loud or in your head first, then compare.
Answer
These are Pages Router APIs, i.e. the pages/ directory.
getServerSideProps fetches data on the server for every request to the page. getStaticProps is for static generation — usually at build time, and with ISR also during regeneration.
JSX
// pages/profile.jsx — outline
export async function getServerSideProps() {
return { props: { generatedAt: new Date().toISOString() } };
}
export default function Profile({ generatedAt }) {
return <p>{generatedAt}</p>;
}Pitfall: I don't carry these functions over to app/. The App Router uses a different data-fetching and caching model. Props are sent to the client — I don't put secrets in them.
How did it go? Be honest — “Not yet” puts the question on your review list.