Explain client-side rendering, server-side rendering and static site generation. When would you use each?
What the interviewer wants to hear
- CSR renders in the browser after JavaScript loads
- SSR renders HTML on the server for each request
- SSG builds HTML at build time and serves it from a CDN
- Trade-offs in SEO, speed, freshness and server cost
- Frameworks like Next.js mix these per route
Model answer
With client-side rendering, the server sends a mostly empty HTML page and JavaScript builds the UI in the browser. It is fine for dashboards behind a login where SEO does not matter, but the first load can be slow. With server-side rendering, the server builds HTML for each request, so the user and search engines see content quickly and the data is always fresh, but each request costs server time. Static site generation builds pages at build time and serves them from a CDN, which is the fastest and cheapest, and great for blogs, docs and marketing pages, but data can be stale until you rebuild or revalidate. In Next.js I can mix them: static pages for marketing, revalidated static pages for product listings, dynamic server rendering for personalized pages, and client components only where I need interactivity.
Can you answer it under time pressure?
Take a timed easy round and get scored on every answer.
More easy Full Stack Developer questions
- What happens, step by step, when a user types your app URL into the browser and presses Enter?
- Design the REST API endpoints for a simple blog with posts and comments. What URLs, methods and status codes would you use?
- What is the difference between authentication and authorization? Give an example from a web app.
- You are starting a new e-commerce app. Would you choose a SQL or a NoSQL database, and why?
- In a web app with a React frontend and an API, where should input validation happen, and why?
- A page loads data from your API. How do you handle loading, empty and error states so users are never left confused?
- How do you manage configuration and secrets across development, staging and production for a full-stack app?
- How would you explain a database index to a junior developer, and how do you decide which columns to index?
- Describe the Git and code review workflow you follow when building a feature on a team.