Next Interview
Next Interview
👉 SSR (Server-Side Rendering): The page is generated on the server before sending
it to the browser.
📌 Example: News websites like Times of India – every refresh fetches fresh data.
👉 CSR (Client-Side Rendering): The page loads first, and data is fetched later on
the client side.
📌 Example: User dashboards – data changes frequently, so CSR is better.
2.Explain the difference between App Router and Page Router in Next.js.
👉 Page Router (Old Next.js, before v13): Uses pages/ folder, everything is file-
based.
👉 App Router (Next.js 13+): Uses app/ folder, follows folder-based routing,
supports React Server Components.
📌 Example: Old Next.js is like a manual car, you control everything. New Next.js
(App Router) is like automatic transmission, optimized and easier to use.
3.How has Next.js changed from older versions to the latest versions?
👉 Before Next.js 13: Fully client-side heavy, page-based routing.
👉 After Next.js 13+: Server Components, parallel routes, optimized API calls.
📌 Example: Manual vs. Automatic car analogy – older Next.js needed more control,
while Next.js 15+ is optimized for performance.
An ATM machine remembers your PIN even after the transaction is done.
When ordering food in a restaurant, you place an order (async task), and the waiter
(event loop) keeps checking if the food is ready without stopping.
Reminder App: You set a reminder for 10 minutes, and it pops up after the delay.
Binary Search: Finding a name in an alphabetically sorted phone book (O(log n)).
📌 Think of it like:
💡 Example: Imagine editing a Google Doc—only the changes sync, not the entire
document.
💡 Example: A video streaming app loads essential content first, then buffers in the
background.
💡 Example: In an e-commerce cart, if a user removes an item, React uses the key to
update only that item instead of reloading the entire cart.
💡 Example: useState for a toggle button, useReducer for managing a shopping cart.
💡 Example: Use useMemo for expensive calculations (e.g., filtering a large dataset)
and useCallback for event handlers in child components.
💡 Example: A search bar with live filtering is controlled, while a file input
(<input type="file" />) is uncontrolled.
💡 Example: Instead of passing a theme prop from App → Navbar → Button, use Context
API to provide it globally.
💡 Example: <Fragment> prevents unnecessary <div> wrappers that break CSS layouts.
💡 Example: Use React.lazy() for loading a dashboard page only after login.
💡 Example: Blog posts use SSG (cached pages), while user dashboards use SSR (fresh
data)
💡 Example: E-commerce product pages update every 10 minutes without redeploying the
site.
💡 Example: Amazon uses image optimization to load product images faster on mobile.
💡 Example: Blocking users from accessing admin pages without logging in.