May 6, 2026
1 min read
A comparison of getServerSideProps vs getStaticProps — when to use each and how SSR impacts performance, SEO, and API design.
Next.js offers multiple data-fetching strategies. Choosing the right one significantly impacts performance, SEO, and user experience.
Runs on every request — ideal for dynamic, user-specific, or frequently updated data:
export const getServerSideProps: GetServerSideProps = async (context) => {
const data = await fetchFromAPI();
return { props: { data } };
};
Runs at build time — ideal for content that rarely changes:
export const getStaticProps: GetStaticProps = async () => {
const posts = await fetchPosts();
return { props: { posts }, revalidate: 60 };
};
When using getServerSideProps, the fetch runs on the Node.js server — not the browser. This means CORS headers are irrelevant for server-side calls, and you can hit internal APIs directly without exposing them publicly.
Combining SSR and SSG in the same Next.js app lets you optimize each page independently — static where possible, dynamic where necessary.