Next.js Quiz ( Advance ) - All Questions
This advanced Next.js quiz is designed for experienced developers who want to test deep, real-world knowledge of the framework. It focuses on edge cases, performance optimization, rendering trade-offs, middleware, caching, and production-level architecture commonly asked in senior interviews.
Question 1: What is the main architectural benefit of using the App Router over the Pages Router?
- Simpler routing syntax
- Better SEO by default
- Support for React Server Components
- Faster client-side navigation
Explanation: The App Router enables React Server Components, improving performance and data handling.
Question 2: Why are React Server Components beneficial in Next.js?
- They increase bundle size
- They run only in the browser
- They reduce client-side JavaScript
- They replace API routes
Explanation: Server Components reduce the amount of JavaScript sent to the client.
Question 3: What happens if you use a browser-only API inside a Server Component?
- It works normally
- It is ignored
- It throws a runtime error
- It is automatically polyfilled
Explanation: Server Components cannot access browser-only APIs.
Question 4: Which directive explicitly marks a component as a Client Component?
- useClient()
- 'use client'
- 'client-only'
- enableClient
Explanation: The 'use client' directive marks a file as a Client Component.
Question 5: What is the primary role of Next.js middleware?
- Rendering UI components
- Running logic before request completion
- Fetching client-side data
- Handling database migrations
Explanation: Middleware runs before a request is completed, enabling auth, redirects, and rewrites.
Question 6: Where does Next.js middleware execute by default?
- Node.js server
- Browser
- Edge runtime
- Client bundle
Explanation: Middleware runs on the Edge runtime by default.
Question 7: What is a key limitation of Edge runtime compared to Node.js runtime?
- No async support
- Limited access to Node APIs
- No fetch support
- Slower execution
Explanation: Edge runtime does not support many Node.js APIs.
Question 8: Which caching strategy is used by default for fetch in Server Components?
- No caching
- Client-side cache
- Full dynamic cache
- Static cache with revalidation
Explanation: fetch in Server Components is cached by default with revalidation support.
Question 9: How can you force a fetch request to be dynamic?
- cache: 'force-cache'
- revalidate: 0
- cache: 'no-store'
- dynamicFetch: true
Explanation: cache: 'no-store' disables caching and forces dynamic fetching.
Question 10: What does dynamic = 'force-dynamic' do in a route segment?
- Forces static generation
- Disables routing
- Forces dynamic rendering
- Enables ISR
Explanation: It forces the route to be rendered dynamically on every request.
Question 11: Which scenario is NOT suitable for Static Site Generation?
- Marketing pages
- Blog posts
- User-specific dashboards
- Documentation sites
Explanation: User-specific dashboards require per-request data.
Question 12: What is the main risk of excessive Client Components?
- SEO issues
- Larger JavaScript bundle
- Slower server response
- Build failure
Explanation: Client Components increase the client-side JavaScript bundle.
Question 13: Why should authentication logic be handled in middleware or server components?
- For better UI rendering
- To reduce CSS size
- To prevent client-side tampering
- To enable static export
Explanation: Server-side auth prevents exposing sensitive logic to the client.
Question 14: What does revalidateTag enable?
- Route-level caching
- Tag-based cache invalidation
- Client-side refresh
- Middleware execution
Explanation: revalidateTag enables selective cache invalidation using tags.
Question 15: Which Next.js feature helps avoid waterfall data fetching?
- useEffect
- Parallel routes
- Server Components
- Client-side fetching
Explanation: Server Components allow parallel data fetching on the server.
Question 16: What problem do parallel routes solve?
- Dynamic routing
- Loading multiple UI segments independently
- API versioning
- State management
Explanation: Parallel routes enable independent rendering of UI sections.
Question 17: What is the purpose of route groups in the App Router?
- Improve SEO
- Group routes without affecting URL
- Enable authentication
- Optimize images
Explanation: Route groups organize routes without changing the URL structure.
Question 18: Which rendering strategy gives the best Time To First Byte?
- CSR
- SSR
- SSG
- Client hydration
Explanation: SSG serves pre-built HTML instantly.
Question 19: What happens if a Server Component imports a Client Component?
- Build fails
- Client Component is ignored
- Client Component boundary is created
- Everything becomes client-side
Explanation: A client boundary is created where client-side rendering begins.
Question 20: Which scenario benefits most from ISR?
- Real-time chat
- Authenticated dashboards
- Content that updates periodically
- Highly interactive forms
Explanation: ISR is ideal for periodically changing content.
Question 21: What is the main drawback of SSR at scale?
- Poor SEO
- High server cost
- Large HTML files
- No caching support
Explanation: SSR can be expensive due to per-request server computation.
Question 22: Why is streaming important in Next.js?
- It improves image quality
- It sends HTML progressively
- It replaces hydration
- It disables SSR
Explanation: Streaming sends parts of the page as they are ready.
Question 23: Which React feature enables streaming in Next.js?
- Suspense
- useEffect
- useMemo
- Context API
Explanation: Suspense enables streaming and loading boundaries.
Question 24: What is the main use of loading.js in App Router?
- SEO optimization
- Error handling
- Streaming fallback UI
- Client-side routing
Explanation: loading.js provides fallback UI during streaming.
Question 25: What does error.js handle?
- Build errors
- Runtime errors in a route segment
- API errors only
- Middleware failures
Explanation: error.js handles runtime errors within a route segment.
Question 26: Which cache is shared across requests?
- Client cache
- Router cache
- Data cache
- Component state
Explanation: The Data Cache is shared across requests.
Question 27: What does static = 'force-static' enforce?
- Dynamic rendering
- ISR only
- Pure static rendering
- Client-side rendering
Explanation: It enforces static rendering even if dynamic APIs are used.
Question 28: Why should heavy computations be avoided in Client Components?
- They increase server load
- They block the browser main thread
- They break hydration
- They disable caching
Explanation: Heavy computations can block the browser and hurt UX.
Question 29: Which approach best secures sensitive environment variables?
- Expose them to client
- Use NEXT_PUBLIC prefix
- Keep them server-only
- Store in localStorage
Explanation: Server-only environment variables are not exposed to the client.
Question 30: What is the main benefit of colocating data fetching with components?
- Better styling
- Reduced prop drilling
- Smaller CSS
- Improved routing
Explanation: It reduces prop drilling and improves maintainability.
Question 31: Which situation can cause hydration mismatch?
- Consistent server and client output
- Using random values during render
- Static HTML
- Pure Server Components
Explanation: Random or non-deterministic values cause mismatches.
Question 32: Why is CDN caching critical for Next.js at scale?
- It improves CSS loading
- It reduces database usage
- It reduces server load and latency
- It replaces SSR
Explanation: CDN caching reduces latency and server workload.
Question 33: Which rendering strategy is best for A/B testing?
Explanation: SSR allows per-request variations.
Question 34: What does route interception enable?
- Blocking routes
- Rendering routes in different UI contexts
- API versioning
- Auth protection
Explanation: Route interception renders routes in alternative UI contexts.
Question 35: What is the biggest risk of overusing middleware?
- Poor SEO
- Increased latency
- Build failure
- Broken routing
Explanation: Middleware adds execution time to every request.
Question 36: Which strategy minimizes JavaScript sent to the browser?
- Client Components
- Server Components
- CSR
- Hydration
Explanation: Server Components send no JS to the client.
Question 37: Why should fetch logic prefer server-side execution?
- To reduce API cost
- To hide secrets and reduce client JS
- To improve CSS loading
- To enable routing
Explanation: Server-side fetching hides secrets and reduces client bundle.
Question 38: Which Next.js feature helps build resilient UIs?
- error.js
- useState
- Link
- Image
Explanation: error.js enables graceful error handling.
Question 39: What is the primary purpose of Suspense boundaries?
- Caching data
- Handling errors
- Controlling loading states
- Optimizing SEO
Explanation: Suspense controls loading behavior for async components.
Question 40: Which scenario requires Node.js runtime instead of Edge?
- Simple redirects
- Heavy filesystem access
- Auth checks
- Header rewrites
Explanation: Filesystem access requires Node.js APIs.
Question 41: Why is static export incompatible with API routes?
- API routes need server execution
- API routes break SEO
- API routes require middleware
- API routes disable caching
Explanation: Static export produces only HTML with no server.
Question 42: What does the router cache store?
- Fetched data
- Rendered route segments
- Client state
- Middleware results
Explanation: Router cache stores rendered segments for navigation.
Question 43: Which pattern best supports large-scale Next.js apps?
- Client-heavy architecture
- Server-first architecture
- CSR-only approach
- Single rendering strategy
Explanation: Server-first architecture scales better.
Question 44: What is the ultimate goal of Next.js architecture?
- Replace React
- Maximize client-side rendering
- Balance performance, SEO, and DX
- Eliminate JavaScript
Explanation: Next.js balances performance, SEO, and developer experience.