frontend-interview-questions

1. How would you design a frontend system to handle a high-traffic e-commerce platform with millions of concurrent users?

Key strategies :

const Product = React.lazy(() => import("./Product"));


2. What’s your approach to designing a frontend architecture that supports real-time updates across multiple clients (e.g., a chat app or live dashboard)?

Approach :

socket.on("newMessage", (msg) => {
  dispatch(addMessage(msg));
});


3. How do you design a frontend system that can seamlessly switch between online and offline modes?

Techniques :

window.addEventListener("online", syncQueuedRequests);


4. How would you architect a frontend system to support internationalization (i18n) and localization (L10n) for a global audience?

Architecture :

i18n.changeLanguage("fr"); // dynamically switches language


5. What’s your strategy for designing a frontend system that integrates with a microservices backend?

Strategy :


6. How do you design a React application to minimize bundle size and optimize initial load time for a large-scale app?

Tactics :


7. How would you design a frontend system to handle pagination, infinite scrolling, and large datasets (e.g., 100,000+ records)?

Best Practices :

<FixedSizeList height={600} itemSize={35} itemCount={items.length}>
  {Row}
</FixedSizeList>


8. What’s your approach to designing a frontend caching strategy to reduce redundant API calls in a React application?

Layers of caching :


9. How do you design a frontend system to handle peak traffic spikes (e.g., Black Friday sales) without degrading performance?


10. How would you architect a React application to support progressive web app (PWA) features like push notifications and offline caching?

Architecture :

self.addEventListener('push', event => {
  self.registration.showNotification('New Offer!', {...});
});


11. How do you design a state management system for a React app with complex, interdependent UI components?

Approach :


12. What’s your approach to designing a frontend system that syncs data bidirectionally with a backend in real time (e.g., collaborative editing)?

Pattern :

editor.onChange = (change) => socket.emit('doc:update', change);


13. How would you design a frontend system to manage client-side data persistence across page refreshes and sessions?

Tools :

localStorage.setItem('theme', 'dark');


14. How do you design a frontend system to handle rate-limited or unreliable APIs without compromising user experience?

Strategies :

axiosRetry(api, { retries: 3, retryDelay: exponentialDelay });


15. What’s your approach to designing a frontend system that supports optimistic UI updates while ensuring data integrity with the backend?

Flow :

  1. Immediately update UI state (e.g., like a post).
  2. Send async request to backend.
  3. On error, rollback to previous state.
mutation.mutate(updateItem, {
  onMutate: () => updateCacheLocally(),
  onError: () => rollback(),
});

Use react-query or a custom mutation manager for tracking.


16. How do you design a frontend system to work with a GraphQL backend versus a RESTful backend?

Key differences :

const { data, loading } = useQuery(GET_PRODUCT, { variables: { id } });

REST Strategy :


17. How would you architect a frontend system to integrate with a legacy backend that has inconsistent APIs and slow response times?

Approach :

async function getNormalizedUser(id) {
  const raw = await legacyAPI.get(`/user/${id}`);
  return { name: raw.username, age: raw.details?.age ?? null };
}


18. What’s your approach to designing a frontend system that supports A/B testing and feature toggles at scale?

System Design :

{
  featureFlags.newCheckout ? <NewCheckout /> : <LegacyCheckout />;
}


19. How do you design a frontend system to collaborate with a backend team using a contract-first approach (e.g., OpenAPI, GraphQL schemas)?

Best Practices :

// types generated from GraphQL schema
type GetUserQuery = {
  user: { id: string, name: string },
};


20. How would you design a frontend system to support multiple deployment environments (e.g., dev, staging, prod) with different configurations?

Approach :

const apiBase = process.env.REACT_APP_API_URL;


21. How do you design a frontend system to gracefully handle browser compatibility issues across a wide range of devices and versions?

Techniques :

if (!window.fetch) {
  loadPolyfill().then(initApp);
}


22. What’s your approach to designing a frontend system with zero-downtime deployments?

Practices :

<script src="/static/js/main.[hash].js" defer></script>


23. How do you design a frontend monitoring system to track performance, errors, and user behavior in production?

Tooling :

reportWebVitals((metric) => sendToAnalytics(metric));


24. How would you architect a frontend system to support long-term maintenance by a team of varying skill levels?

Strategies :

"scripts": {
  "lint": "eslint src --ext .js,.ts,.tsx",
  "typecheck": "tsc --noEmit"
}


25. What’s your approach to designing a frontend system that can recover from catastrophic failures (e.g., corrupted state, network outages)?

Defense Strategy :

<ErrorBoundary fallback={<Fallback />}>
  <Dashboard />
</ErrorBoundary>