← Zettabyte Interview Insights

Zettabyte·Frontend Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Technical screen at Zettabyte for a frontend role. Most of the conversation centered on state management architecture, specifically how Zustand and TanStack Query fit together (or don't). Felt pretty solid on the conceptual stuff but stumbled a bit when they pushed on the anti-patterns.

Questions Asked (3)

Q1

What is Zustand used for, and how does it differ from TanStack Query in a React application?

Technical Trade-offsSystem Design
Author's notes

I knew this one well enough.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining Zustand as a lightweight client-state management library and TanStack Query as a server-state management library. Then contrast their core purposes, typical use cases, and how they can complement each other in a React app. Use a concrete example to illustrate when to use each.

Pro tip: Emphasize that Zustand and TanStack Query solve different problems and are often used together; avoid framing them as competitors. Mention that TanStack Query handles caching, deduplication, and background updates for server data, while Zustand manages global client state like UI themes or auth tokens.

1. Define Zustand

Explain that Zustand is a minimal, hook-based state management library for React, ideal for global client state such as user preferences, UI toggles, or shopping cart data.

2. Define TanStack Query

Describe TanStack Query as a data-fetching and server-state management library that handles caching, synchronization, and updates for asynchronous data from APIs.

3. Contrast core purposes

Highlight that Zustand manages client state that is synchronous and local to the app, while TanStack Query manages server state that is asynchronous and remote.

4. Discuss complementary use

Explain that they are not mutually exclusive; you can use TanStack Query for server data and Zustand for global client state, often in the same application.

5. Provide a concrete example

Give a scenario, such as a dashboard where TanStack Query fetches user data and Zustand stores the dark mode preference, to illustrate the division of responsibilities.

Key Points to Mention

  • Zustand is for client state; TanStack Query is for server state.
  • TanStack Query provides built-in caching, deduplication, and background refetching.
  • Zustand is lightweight, unopinionated, and uses hooks for state management.
  • They can be used together: TanStack Query for data fetching, Zustand for global UI state.
  • Zustand does not handle asynchronous data fetching or caching out of the box.
  • TanStack Query is not a replacement for a global state manager like Zustand.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

What's wrong with storing fetched server data inside a Zustand store and writing your own refetch logic around it?

Technical Trade-offsSystem Design
Author's notes

This is where I think I undersold myself.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Acknowledge that Zustand can store server data, but explain that it's an anti-pattern because it duplicates state and requires manual synchronization. Then discuss the trade-offs: increased complexity, potential for stale data, and missed optimizations from dedicated data-fetching libraries. Finally, recommend using a server-state management tool like React Query or SWR, while using Zustand for client state.

Pro tip: Emphasize that the core issue is treating server state as client state; server state is asynchronous, shared, and needs caching, deduplication, and background updates—features that are hard to replicate manually. Mention that mixing them leads to bugs and maintenance headaches.

1. Clarify the distinction between server state and client state

Explain that server state is persisted remotely, requires async fetching, and can become stale, while client state is local and synchronous. Storing server data in Zustand blurs this line.

2. Identify the problems with manual refetch logic

Discuss issues like race conditions, cache invalidation, deduplication of requests, and lack of automatic background updates. Manual logic is error-prone and time-consuming.

3. Highlight the trade-offs and costs

Mention increased code complexity, potential for stale or inconsistent data, and the burden of maintaining custom caching and synchronization. This can lead to bugs and poor user experience.

4. Recommend the right tool for the job

Suggest using dedicated server-state libraries like React Query, SWR, or RTK Query that handle caching, deduplication, and background refetching out of the box. Use Zustand for client state only.

5. Summarize the best practice

Conclude that separating server state from client state leads to cleaner, more maintainable code and better performance. If needed, you can integrate server-state libraries with Zustand for specific use cases.

Key Points to Mention

  • Server state is asynchronous, shared, and can become stale; client state is local and synchronous.
  • Manual refetch logic often leads to race conditions, cache invalidation issues, and duplicated requests.
  • Dedicated server-state libraries (React Query, SWR) provide built-in caching, deduplication, and background updates.
  • Storing server data in Zustand increases complexity and maintenance burden.
  • Mixing server and client state can cause bugs and inconsistent UI.
  • Best practice: use Zustand for client state and a server-state library for server data.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q3

Can you describe a scenario where you'd use both Zustand and TanStack Query together in the same feature?

Technical Trade-offsAPI & Integrations
Author's notes

Actually enjoyed this one.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Choose a concrete feature like a paginated, filterable list with optimistic updates, and explain how TanStack Query handles server state (fetching, caching, synchronization) while Zustand manages client state (UI filters, selected items, modal visibility). Emphasize the clear separation of concerns and how they complement each other without overlap.

Pro tip: Mention that you avoid duplicating server data in Zustand—treat TanStack Query as the single source of truth for server state, and use Zustand only for ephemeral UI state. This shows you understand the pitfalls of state duplication and cache invalidation.

1. Set the context

Briefly describe the feature and why it needs both server and client state management. For example, a product list with filters, sorting, and a shopping cart.

2. Assign responsibilities

Explain what TanStack Query handles: fetching, caching, background refetching, pagination, and mutations. Then explain what Zustand manages: filter values, sort order, selected items, and UI toggles.

3. Show integration

Describe how they interact: Zustand stores the filter state, which is passed as query keys to TanStack Query. When filters change, TanStack Query automatically refetches. Mutations update the server and invalidate queries, while Zustand might handle optimistic UI updates for local actions.

4. Highlight benefits

Discuss why this separation is beneficial: avoids prop drilling, reduces unnecessary re-renders, keeps server cache consistent, and simplifies testing and debugging.

5. Address trade-offs

Acknowledge potential complexity, such as syncing state between the two, and how you mitigate it (e.g., keeping Zustand minimal, using query keys effectively).

Key Points to Mention

  • Separation of server state vs. client state
  • TanStack Query for data fetching, caching, and synchronization
  • Zustand for global UI state (filters, modals, selections)
  • Using query keys derived from Zustand state to trigger refetches
  • Optimistic updates and cache invalidation with mutations
  • Avoiding duplication of server data in Zustand

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.