0%
Frontend System Design Interviews: Components, Rendering, State, Caching and Performance
State Management on the Client
State management is the part of a frontend design where many candidates either say too little or far too much. Too little sounds like we will use Redux. Too much sounds like a ten minute tour of every library they have ever installed. The interviewer wants neither. They want to see that you can look at a screen, list what the screen needs to know, sort that information by who owns it and how long it lives, and then choose the smallest mechanism that keeps each piece correct. This lesson gives you that sorting method and the trade-offs behind each choice.
This is step three of the framework from the first lesson, data model and state. By the time you reach it you have requirements and a component tree from the architecture step. Now you decide where the data that flows through that tree actually lives.
Why the word state hides four different things
Ask ten engineers what state is and most will describe a variable that changes over time and causes the interface to update. That is accurate and almost useless for design, because it lumps together values with completely different owners, lifetimes and failure modes. A useful design starts by splitting state into kinds.
Server state is data the server owns and the client merely holds a copy of: the list of products, the user's profile, the messages in a thread. The client copy can be stale at any moment because someone else can change the source. Its problems are caching, refetching, deduplication and invalidation.
Client UI state is data that exists only in this browser tab: whether a dropdown is open, which tab is selected, which row is expanded, whether a modal is showing, the scroll position of a panel. Nobody else cares about it and it rarely needs to survive a reload. Its problems are placement and re-render cost.
Form state is the user's unsaved input: the text in a comment box, the fields of a checkout form, the validation errors for each field, whether a field has been touched. It is client owned until submit, and then it becomes a request that changes server state. Its problems are validation timing, dirty tracking, draft persistence and the moment of submission.
URL state is information encoded in the address bar: the route, the search query, the page number, the sort order, the selected filters, the id of an open item. It is client owned but public. It survives reload, it can be shared in a link, and the back button walks through its history. Its problems are serialisation and keeping the address bar and the screen in agreement.
Why the split matters in an interview
Each kind wants a different tool, and most real bugs come from storing one kind in the tool built for another. The classic example is copying server data into a global client store. The team fetches the product list, dispatches it into a store, and from then on the store is the source of truth. Now every mutation needs a manual update in the store, every screen that shows the same product needs to be kept in sync by hand, and nothing ever refetches when the data goes stale. The store has turned a cache problem into a synchronisation problem, which is harder. A dedicated server state layer, which the next lesson on data fetching and caching covers in depth, handles caching, deduplication and refetching for you. For this lesson, treat server state as something you read through that layer, not something you own.
The reverse mistake is also common. Teams put a search query or a selected filter into component memory, and then users cannot share a link to their search, the back button does nothing useful and a reload throws away their work. That state belonged in the URL.
When you list state by kind, you are effectively answering three questions for each item. Who owns the truth: the server, this tab or the address bar? How long must it live: one render, one session, across reloads, across devices? Who needs to read it: one component, a subtree, the whole app? The answers pick the mechanism.
A worked example: a product listing page
Suppose the prompt is an e-commerce product listing with filters, sorting, a cart drawer and a quick view modal. Sorting the state by kind takes about a minute out loud and produces a table like this.
Notice a few decisions hidden in that list. The quick view modal's open item lives in the URL, so a user can paste a link that opens the same product. The cart drawer's open flag does not, because opening the drawer on page load from a shared link would be surprising. The cart contents are server state even though the user edits them, because the server prices them and they must follow the user to another device. The hovered card is pure UI state and lives inside the card component itself.
Interviewers are not checking for these exact answers. They are checking that you made a deliberate choice for each item and can explain it.
Lifetimes and persistence
The second axis is lifetime. Some state lives for a single render and should be a local variable. Some lives while a component is mounted. Some must survive navigation within the app, which means it has to sit above the router or in a store. Some must survive a reload, which means the URL, session storage or local storage. Some must survive a device switch, which means the server.
Persistence is a trade. Writing a long checkout form draft to local storage protects the user from losing ten minutes of typing when the tab crashes. It also means you must handle stale drafts from an older version of the form, clear drafts on submit and avoid writing sensitive data such as card numbers to storage at all. Saying this out loud is a strong signal, because it shows you think about state across time, not only within one render.
A practical rule: default to the shortest lifetime that meets the requirement. Short lived state cannot go stale, cannot leak between users on a shared machine and does not need migration when the shape changes. Lengthen the lifetime only when a requirement asks for it, such as resuming a draft, sharing a link or keeping a filter while the user moves between pages.
URL state done well
The URL is the most underused state container in frontend designs. Anything a user would reasonably want to bookmark, share, reload or reach with the back button belongs there: the route, the search query, filters, sort, page or cursor, the selected tab on a details page and the id of an open item or modal.
Treat the URL as the source of truth for that state, not as a copy. Components read filters from the URL, and changing a filter writes the URL, which then drives the screen. If you instead keep filters in component state and mirror them into the URL, the two can disagree, for example after a back navigation that changes the URL without telling the component.
Push or replace, and other URL details
Each URL change either pushes a new history entry or replaces the current one. Push when the change is a navigation the user would expect the back button to undo, such as opening a product or changing a category. Replace when the change is a refinement that would otherwise flood the history, such as each keystroke in a search box or each pan of a map. A common combination is to replace on each debounced keystroke and push when the user presses enter or picks a suggestion.
Other details show care. Validate and normalise URL parameters, because users edit them and old links carry values that no longer exist. Reset dependent state when a parent changes: changing the category should drop the page number. Keep the URL readable and stable, with short parameter names and a canonical order, because it will appear in analytics, logs and shared messages. Avoid putting sensitive data in the URL, because it ends up in history, server logs and referrer headers.
URL state and rendering
URL state also matters for rendering strategy. If filters live in the URL, a server rendered or statically generated page can render the right results on the first response, and search engines can index category and filter pages if the product wants that. If filters live only in client memory, the first response is always the unfiltered page. The rendering strategies lesson covered this choice; here the point is that putting state in the URL is what makes those options possible.
What the interviewer is checking
In this part of the interview, the interviewer listens for three things. First, whether you distinguish server state from client state, because this is the single biggest source of accidental complexity in real frontends. Second, whether you think about the URL as a place to store state, because forgetting it breaks sharing, reload and the back button, which users notice immediately. Third, whether your choices follow from the requirements you gathered earlier. If the requirements said users share search results with teammates, the filters must be in the URL. If they said the app must work offline, some state needs durable storage.
A short summary at the end of the step works well. Something like: server data goes through a query cache with per resource keys, view state stays local to the components that render it, filters and the open item live in the URL, and the long form draft persists to session storage. That one sentence gives the interviewer a map of the whole design and invites them to pick the part they want to probe.
When a team says their global store is out of sync, the store is usually holding a copy of server data. Move server data into a query cache keyed by resource and the store shrinks to a handful of UI flags that rarely cause trouble.