Build time, request time, and browser time
Choose when work happens from freshness, identity and interaction requirements, while keeping rendering and caching as separate decisions.
What you will be able to do
- Explain build-time, request-time and browser work using one product page.
- Separate Server Components from static rendering and cache policy.
- Design experiments that distinguish production behavior from development behavior.
Ask when the inputs become available
Build-time work can use inputs available when the application is produced. Request-time work can use the current request, such as a verified user identity. Browser-time work can use local interaction and browser APIs. This timing question is separate from component type: a Server Component can participate in prerendering or request rendering, and a Client Component can contribute initial server-generated HTML before it becomes interactive.
For a product page, an editorial description may tolerate reuse, inventory may need a specific freshness rule, and the user’s cart controls need interaction. Treat those as different requirements even though they appear in one screen. Do not choose one rendering label for the entire product before considering which parts depend on what. A useful design starts with data ownership and acceptable staleness, then selects framework mechanisms.
Rendering policy follows observable constraints
A public article can be useful as a reusable prerendered result. A personalized account balance depends on identity and current data and must not be accidentally shared across users. A page with a stable shell and request-specific content can benefit from streaming boundaries and the appropriate caching model. These are product constraints, not performance slogans. Faster wrong data is still wrong, and request rendering is not inherently evidence of poor design.
Be explicit about the framework version and configuration. This course distinguishes Cache Components from the previous App Router caching model. Do not copy a route-level flag from an older tutorial into a different mode and assume it has the same meaning. The code below is an illustrative request-time example under the previous model, with Cache Components disabled. It is intentionally labeled rather than presented as a universal configuration.
Server execution
import { cookies } from 'next/headers';
export default async function DashboardPage() {
const store = await cookies();
const displayMode = store.get('display-mode')?.value === 'compact' ? 'compact' : 'comfortable';
return <main><h1>Dashboard</h1><p>Requested display mode: {displayMode}</p></main>;
}A computation and a cached result are different things
A server computes output; a cache can reuse an earlier result under a defined identity and lifetime. Those operations should not be conflated. A log inside a data function may disappear on a cache hit while a user still sees valid content. A browser navigation may reuse prefetched information. Conversely, an uncached data read does not automatically imply that every unrelated part of the screen must be recomputed from scratch.
The exercise uses an explicit teaching policy for operation placement. An operation requiring request identity is assigned to request time; one requiring a browser API to browser time; public immutable content to build time. Real applications can combine phases and have additional constraints. The purpose is to explain a decision from inputs rather than memorize that server means request and client means no server rendering.
Use a production build for rendering claims
Development prioritizes feedback, diagnostics and rapid updates. Production builds can prerender work, optimize bundles and expose restrictions that were easy to miss while developing. Record the build output, start that build, then compare direct visits, repeated visits and navigation. Use terminal logs, response headers and browser requests together; any one signal can be ambiguous in isolation.
An interview answer should include a correctness requirement, a chosen timing policy, its tradeoff and a verification method. For example: public descriptions can be reused, user-specific data is checked per request, and buttons hydrate for interaction. I verify with a fresh document and two distinct sessions, then measure response and interaction timing. That explanation remains useful when API names change because the underlying constraints are explicit.
Misconceptions to replace
Compare the tempting shortcut with the model you can verify in code.
- CLAIM TO CHALLENGEA browser-only preference and a verified request session can use the same trust model.
- A more accurate model
Browser preferences may guide presentation, but protected identity must be established by the server. Timing and trust must both be named.
- How to check it
N19 and N20 cover data security and authentication; the rendering lesson distinguishes browser and request inputs.
- CLAIM TO CHALLENGECaching personalized data is safe whenever the function runs on the server.
- A more accurate model
The cache identity, authorization, lifetime and isolation policy must preserve the viewer’s access. Server location alone does not prevent cross-user reuse.
- How to check it
N19, N20 and the cache-components lesson describe identity and safe data boundaries.
Mistakes to catch in your own code
- Do not equate Server Component with dynamically rendered on every request.
- Do not equate Client Component with browser-only initial rendering.
- Do not mix cache configuration models or infer production behavior from development logs alone.
Write it by hand
JavaScript logic playground
Choose an execution phase from explicit requirements
Implement solve(input). This sandbox runs the lesson's logic with FrontendX's isolated code runner. Next.js server behavior is verified in the project lab below.
- Implement solve({operations}). Each operation has id and requires equal to browser, request, mutable-public or immutable-public.
- Return an array of {id,phase,reason}. Map browser to browser/browser-api, request to request/request-context, mutable-public to request/fresh-public-data and immutable-public to build/reusable-public-data.
- This is the stated exercise policy, not a Next.js automatic rendering classifier. It deliberately omits caching and mixed-phase components.
Tab moves to the next control. Use spaces to indent and return your answer from solve. Console output is not retained.
Inspect 4 test cases
- A mixed product screen
Input
{ "operations": [ { "id": "description", "requires": "immutable-public" }, { "id": "stock", "requires": "mutable-public" }, { "id": "button", "requires": "browser" } ] }Expected
[ { "id": "description", "phase": "build", "reason": "reusable-public-data" }, { "id": "stock", "phase": "request", "reason": "fresh-public-data" }, { "id": "button", "phase": "browser", "reason": "browser-api" } ] - Session depends on request
Input
{ "operations": [ { "id": "viewer", "requires": "request" } ] }Expected
[ { "id": "viewer", "phase": "request", "reason": "request-context" } ] - Browser-only capability
Input
{ "operations": [ { "id": "local-draft", "requires": "browser" } ] }Expected
[ { "id": "local-draft", "phase": "browser", "reason": "browser-api" } ] - No operations
Input
{ "operations": [] }Expected
[]
Reveal the worked solution and reasoning
function solve(input) {
const policy = {
browser: ['browser', 'browser-api'],
request: ['request', 'request-context'],
'mutable-public': ['request', 'fresh-public-data'],
'immutable-public': ['build', 'reusable-public-data']
};
return input.operations.map(operation => {
const [phase, reason] = policy[operation.requires];
return { id: operation.id, phase, reason };
});
}The output includes a reason, making placement reviewable against a requirement.
Real Next.js rendering can combine phases; the lab must test the actual configuration instead of interpreting this policy table as framework behavior.
Verify it in a real Next.js application
Next.js application lab
Compare public cached reads with request-specific reads
Open the local application route /dashboard after starting the workbench. Follow the experiment and collect the evidence described below.
Make the change
- Read next.config.ts: this project already enables Cache Components and partialPrefetching. Follow the README to stop development, build and start a production server.
- Compare /catalog, /catalog/keyboard and /dashboard through direct visits and internal navigation. Record build output, server logs and relevant browser requests.
- Sign in as Ada, inspect the North dashboard, then switch to Grace and inspect South. Call the task endpoint directly as well as navigating through the UI.
- As a temporary instrumentation exercise, log inside getCatalog and currentUser with distinct labels. Rebuild, make repeated requests and describe when cached work is reused and when cookie-based request work runs. Remove the logs afterward.
Check the behavior
- Public and protected routes work as direct production-mode visits.
- The protected view and task API follow the current server-verified identity.
- The observations name the enabled caching model and separate build-time work from request-time work.
- The report explains why repeated UI appearance or a single console message cannot establish the complete rendering policy.
Review the application reasoning
The configured Cache Components application is the baseline, not a missing extension. Testing another rendering model requires a separate configuration experiment and compatibility review.
Use response, build and browser evidence together. A cached public read and a request-specific protected read can coexist in the same application.
Open the project files and run instructions
A complete App Router application with catalogue routing, cart state, a task dashboard, practice sessions, tenant checks, cached data, hydration repairs, and HTTP streaming. Next.js 16.4.6 and React 19.3.0 are pinned in the project.
The playground opens a new editable copy. A local Node.js 22.14+ installation also runs the project. Use the local production build when measuring caching, streaming, or deployment behavior.
cd nextjs-interview-lab
npm ci
npm run dev
# In a second terminal
npm test
# Stop dev, then verify the production application
npm run build
npm start
# In a second terminal, install the test browser once
npx playwright install chromium
npm run test:e2eOpen http://localhost:3003. The project includes a credential-free practice account selector and a single-process file store. Those choices make experiments reproducible; the security and deployment lessons show what a production system needs.
Explain it in an interview
Give your answer aloud before opening the explanation. Then answer the follow-ups using your implementation as evidence.
01Are React Server Components and server-side rendering the same thing?
No. Server Components define a component and module execution model with a serialized representation. Server rendering describes producing HTML outside the browser. A Server Component may run during prerendering or at request time, while client components can also participate in initial server-generated HTML.
Follow-up questions
- Which code is sent to the browser?
- What makes a route request-dependent?
- Server and client boundaryOfficial documentation
- Server and Client ComponentsOfficial documentation
02How would you render a product page with fast-changing inventory?
I separate reusable product information from inventory freshness and interactive controls. Then I choose explicit cache and rendering rules for each part, including what staleness is acceptable. I would not rely on a single static-versus-dynamic label to justify every field or make a blanket claim that all fetches share one default.
Follow-up questions
- What changes when stock must be exact?
- Which value must be rechecked during purchase?
- Fetching dataOfficial documentation
- Caching with Cache ComponentsOfficial documentation
- GreatFrontEnd Next.js interview questionsPublisher practice bank
03Why test with next build and next start?
They exercise the production build and runtime, where prerendering, optimization and framework constraints may differ from development behavior. I use a reproducible scenario and inspect output and requests. A development screenshot does not establish cache behavior, bundle size or production route correctness.
Follow-up questions
- Which failures can appear only during prerendering?
- How can you avoid mistaking cache hits for missing execution?
- Self-hosting Next.jsOfficial documentation
- CompleteFrontend Next.js question bankPublisher practice bank
04Can you cache personalized data?
Only with an explicit identity and policy that preserve authorization and freshness requirements. A globally shared key for user-specific data is unsafe. I first verify the viewer, decide whether caching is appropriate, and ensure the key or isolated scope represents the relevant identity; cache reuse never replaces permission checks.
Follow-up questions
- What happens when permissions change?
- Which outputs should be public DTOs?
- Data securityOfficial documentation
- Authentication with Cache ComponentsOfficial documentation
Check your understanding
Answer these without reopening the worked examples. The feedback explains the reasoning and the misconception behind each choice.
Your checkpoint
Loading your local progress.
Sources and further reading
- Upgrade to Next.js 16Official documentation
- Server and client boundaryOfficial documentation
- Server and Client ComponentsOfficial documentation
- Fetching dataOfficial documentation
- Caching with Cache ComponentsOfficial documentation
- Caching without Cache ComponentsOfficial documentation
- Data securityOfficial documentation
- Authentication with Cache ComponentsOfficial documentation
- Self-hosting Next.jsOfficial documentation
- GreatFrontEnd Next.js interview questionsPublisher practice bank
- CompleteFrontend Next.js question bankPublisher practice bank