Skip to content
Tutorials Center
My learning

Topics

Lesson 39 of 39 ยท Projects and Practice

Interview Questions and Answers

Prepare for Remix and React Router framework interviews: loaders, actions, errors, sessions, caching, streaming, testing and deployment, with short answers, pitfalls and a self-test.

Interviewers rarely ask you to recite an API. They ask why a design works and what goes wrong when it does not. This lesson collects the questions that come up most often about the second half of this course (errors, sessions, performance, testing, deployment), with answers short enough to say aloud and the follow-ups that usually come next. Use it as a self-test: read the question, answer it out loud, then compare.

A note on names: Remix v2 and React Router v7 framework mode are the same lineage. Remix's ideas now live in React Router, so most answers apply to both; imports differ (@remix-run/node versus react-router).

Errors

What does an ErrorBoundary export do, and which one renders? It catches errors thrown in that route's loader, action or render, and in child routes without their own. The nearest one above the failing route renders in its place; layouts above remain. Navigating resets it.

When do you throw a response and when do you return errors? Throw for failures that stop the page (404, 403, redirect to login). Return errors from the action for things the user fixes by retyping (validation), so the form stays with its values.

What is a soft 404? A not-found page served with status 200. Crawlers may index it. Throw a 404 response from the catch-all route's loader.

Where do you log unexpected errors? In the handleError export of the server entry (skipping aborted requests), and report browser errors from the boundary. Production hides error messages from the client on purpose.

Sessions and authentication

How does a session work in a framework with no global state? A cookie holds either the whole signed session (cookie storage) or a session ID that points at data in a database. Code reads the Cookie header, calls getSession, and writes changes back with commitSession in a Set-Cookie header.

Signed versus encrypted cookies? Signing detects tampering but the content stays readable. Do not put secrets in a signed cookie; use a server-side store or encrypt.

How do you protect a nested route? Check in every loader and action that returns private data, because parent and child loaders run in parallel. A shared requireUserId helper throws a redirect. Enforce ownership in queries, not in the interface.

How do you defend against session fixation, CSRF and open redirects? Rotate the session on login; use SameSite cookies plus an origin or token check on non-GET requests; accept only local return paths.

Node.js Self-test: spot the bug in a login action

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

Performance

How does streaming work? Return an unawaited promise from the loader. The server sends the shell with a Suspense fallback, keeps the response open and sends the resolved value in a later chunk; Await swaps it in. Await anything that decides the status code or the title.

How do you cache a public page safely? Export headers with public, max-age, s-maxage, stale-while-revalidate; never cache pages with user data (private, no-store); purge on publish. Fingerprinted assets are immutable for a year.

What does prefetch="intent" do? Fetches the next route's chunk and data on hover or focus, hiding most latency. Use render and viewport sparingly.

Why can loaders be faster than fetching in useEffect? They start before the component renders and run in parallel across nested routes, avoiding render-then-fetch waterfalls, and on the server they put the data in the first HTML.

Node.js Self-test: predict the order of events

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

Testing and deployment

How do you test a loader? Call it as a function with a real Request and params; assert on the return value; use rejects for thrown responses; mock the database and clock only.

How do you test a component that uses useLoaderData? Wrap it with createRoutesStub, provide fake loaders and actions, render, and query by role and label with findBy.

What does the build produce, and what are the hosting options? Static client assets plus a server request handler (Request to Response). Run it with a Node server or container, serverless platforms or edge workers. Place compute near the database and check Node API support on edge.

Where do secrets go? In server-only environment variables read from .server modules; client-prefixed variables and loader data are public.

Design questions to practice

  1. Design login with a "remember me" option. (Longer maxAge, rotate IDs, server-side store so you can revoke.)
  2. A product page is slow because of recommendations. What do you change? (Stream the promise, add a fallback, cache the shell.)
  3. A user reports seeing someone else's name in the header. Where do you look first? (A shared cache storing a page with Set-Cookie or user data; fix with private, no-store and a separate per-user fetch.)
  4. How would you migrate from cookie sessions to a database store? (Swap the storage module; the route code keeps calling getSession, commitSession, destroySession.)

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. A loader returns an unawaited promise. What does the visitor see first?

    Streaming sends the shell immediately and the promise's result as a later chunk.
  2. 2. What is the correct reaction to a report that one user saw another user's data?

    Shared caches must never hold personalized pages.
  3. 3. Which test approach fits a component that calls useLoaderData?

    The stub supplies a router and data so the component behaves as in the app.
  4. 4. Why is a signed cookie not suitable for secrets?

    Signing is integrity, not confidentiality.

Summary

  • Know the reasons behind the APIs: boundaries bubble, throw versus return, signed versus encrypted, loaders versus effects.
  • Be ready to spot security and caching mistakes in code you are shown.
  • Practice the design questions out loud, naming the trade-offs.

Back to the track page: Remix and React Router Framework