React · Ecosystem

Ecosystem Interview Questions
With Answers & Code Examples

4 carefully curated Ecosystem interview questions with working code examples and real interview gotchas.

Practice Interactively →← All Categories
4 questions0 beginner3 core1 advanced
Q1Core

What is the difference between Next.js Pages Router and App Router?

💡 Hint: Pages Router = getServerSideProps/getStaticProps; App Router = RSC by default, layouts, streaming

Next.js 13+ introduced the App Router as a complete architectural shift:

FeaturePages RouterApp Router
Default component typeClient componentServer component
Data fetchinggetServerSideProps, getStaticPropsasync/await in component
Layouts_app.tsx + manuallayout.tsx nesting
Loading statesManualloading.tsx (Suspense)
Error handlingManualerror.tsx (Error Boundary)
Streaming✅ built-in
// App Router — data fetching is just async/await
// app/users/page.tsx
async function UsersPage() {
  const users = await fetch('/api/users').then(r => r.json());
  return ;
}

// Pages Router equivalent
export async function getServerSideProps() {
  const users = await fetch('/api/users').then(r => r.json());
  return { props: { users } };
}
export default function UsersPage({ users }) {
  return ;
}
💡 The App Router is the future of Next.js. New projects should use it. The Pages Router is in maintenance mode — it won't be removed but new features land in App Router only.
Practice this question →
Q2Core

What is TanStack Query (React Query) and what does it solve?

💡 Hint: Async state manager for server data — caching, background refetch, stale-while-revalidate, mutations

React Query manages server state with automatic caching, background updates, and synchronization — things you'd have to build manually with useEffect.

import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';

// ─── Query — fetch and cache ──────────────────────────────────────────────────
function UserProfile({ id }) {
  const { data: user, isLoading, error } = useQuery({
    queryKey: ['user', id],      // cache key — same key = same cache
    queryFn: () => api.getUser(id),
    staleTime: 5 * 60 * 1000,   // treat as fresh for 5 minutes
    gcTime: 10 * 60 * 1000,     // keep in cache for 10 minutes
  });

  if (isLoading) return ;
  if (error) return ;
  return 

{user.name}

; } // ─── Mutation — update and invalidate ──────────────────────────────────────── function UpdateUser() { const queryClient = useQueryClient(); const mutation = useMutation({ mutationFn: (data) => api.updateUser(data), onSuccess: (data) => { // Invalidate cache → triggers refetch of all user queries queryClient.invalidateQueries({ queryKey: ['user'] }); // OR optimistic update queryClient.setQueryData(['user', data.id], data); }, }); return ( ); }
💡 React Query eliminates ~80% of what people used Redux for — loading states, error states, cached server data, and refetch logic. Use Redux or Zustand only for genuine UI state (modals, sidebars, form wizards).
Practice this question →
Q3Core

What is Zustand and how does it compare to Context?

💡 Hint: Store-based state with subscription model — only components subscribing to a specific slice re-render
import { create } from 'zustand';

// Define the store
const useCartStore = create((set, get) => ({
  items: [],
  total: 0,

  addItem: (item) => set(state => ({
    items: [...state.items, item],
    total: state.total + item.price,
  })),

  removeItem: (id) => set(state => {
    const item = state.items.find(i => i.id === id);
    return {
      items: state.items.filter(i => i.id !== id),
      total: state.total - (item?.price ?? 0),
    };
  }),

  clearCart: () => set({ items: [], total: 0 }),
}));

// Consume — component only re-renders when items changes
function CartBadge() {
  const items = useCartStore(state => state.items); // subscribe to slice
  return {items.length};
}

// Another component — only subscribes to total
function CartTotal() {
  const total = useCartStore(state => state.total);
  return ${total};
}

Zustand vs Context:

  • Context — all consumers re-render on any context change. Fine for low-frequency updates (theme, auth).
  • Zustand — subscription-based. Component re-renders only when its specific slice changes. Better for frequent updates and large stores.
  • No Provider needed — Zustand store is a module. Import and use anywhere.
💡 Zustand is intentionally minimal. For derived state, just compute it in the component. Use subscribeWithSelector middleware for more granular subscriptions.
Practice this question →
Q4Advanced

What are the key differences between Vite and Create React App?

💡 Hint: Vite uses native ES modules in dev — instant server start vs CRA's webpack bundle

CRA (Create React App) is largely deprecated. Vite is the modern standard for React projects.

Create React AppVite
Dev server start30-60s (bundles everything)<300ms (no bundling)
HMR (hot reload)Slow (rebundles)Instant (native ESM)
Build toolwebpackRollup (prod), esbuild (dev)
ConfigEjection requiredvite.config.ts
MaintenanceUnmaintainedActively maintained
// Vite dev — serves files directly as ES modules
// Browser requests /src/App.tsx → Vite transforms just that file → instant

// CRA dev — bundles ALL files on start, then watches
// Every change → re-bundle affected module graph → slow

// Starting a new project
npm create vite@latest my-app -- --template react-ts
# vs
npx create-react-app my-app --template typescript  # avoid

Alternatives for production apps:

  • Next.js — SSR, SSG, RSC, file-based routing
  • Remix — full-stack, nested routing, web standards
  • Vite + React Router — SPA with full control
💡 The React team no longer recommends CRA. Their official docs point to Next.js, Remix, or Vite as starting points depending on your needs.
Practice this question →

Other React Interview Topics

Rendering StrategiesCore JSType SystemReact FundamentalsFunctionsMicrofrontendsGenericsAsync JSHooksObjectsMonorepoArrays'this' KeywordUtility TypesError HandlingModern JSBundle OptimizationPerformanceDOM & EventsState ManagementClasses & OOPCaching StrategiesComponent PatternsAdvanced TypesAuthenticationReact RouterFormsAdvanced PatternsFrontend SecurityConcurrent ReactServer ComponentsTestingNetwork OptimizationCore Web VitalsBrowser APIs

Ready to practice Ecosystem?

Get AI feedback on your answers, predict code output, and fix real bugs.

Start Free Practice →