Skip to content
tezvyn:

Frontend

450 bites tagged Frontend — interview questions with model answers, and 60-second explainers.

React & Next.js2 min read

Implement a protected /dashboard route in React Router

Tests declarative route guards versus imperative redirects in React Router 7. Strong answer: reusable ProtectedRoute wrapper with Navigate replace, auth state above Routes, and role checks.

React & Next.js2 min read

Primary roles of BrowserRouter, Routes, and Route, and basic route setup

Tests v6 routing hierarchy. BrowserRouter provides history; Routes picks one match; Route maps path to element. Wrap Routes in BrowserRouter with nested Route elements for / and /about. Red flag: omitting the router or confusing Routes with Switch.

React & Next.js2 min read

Where and how to import global stylesheets in Next.js

This tests Next.js style entry points. In the App Router, import global CSS in the root layout.js; in the Pages Router, import it in _app.js. Never import global styles inside pages or components, since Next.js restricts global CSS to root-level files.

React & Next.js2 min read

Use useContext to provide theme state without prop drilling

This tests global state sharing without prop drilling. A strong answer uses createContext and a Provider with useState at the app root, then calls useContext in nested components. Red flag: ignoring re-render costs or placing the Provider too deep.

React & Next.js2 min read

What is a custom hook? Write a simple useToggle example.

What it tests: Whether you see hooks as stateful logic extraction. Outline: Define a use-prefixed function calling hooks; write useToggle with useState and callback; explain extraction vs duplication. Red flag: Helpers without hooks or missing use prefix.

React & Next.js2 min read

Write the React.createElement() equivalent for this JSX

Tests JSX-to-JS compilation mechanics. Answer: createElement('a', {href: '/home', className: 'link'}, 'Go Home'). Children must be the third argument, not inside props. Red flag: nesting children in props or using an unquoted tag variable.

React & Next.js2 min read

Describe two patterns for conditional rendering in JSX

First, early return with if/else for branches; second, ternary or logical AND inside JSX for inline toggles. Whether you know React conditional rendering. Reaching for useState or useEffect when simple JS suffices.

React & Next.js2 min read

What is the purpose of React's key prop and index key risks?

This tests React reconciliation. Keys give stable identity to match components across renders and preserve state. Indices break on reorder or delete, causing state bugs. A red flag: saying keys are only for performance or indices are harmless.

React & Next.js2 min read

What are the two main ways to define a component in React?

Tests fluency in function and class syntax. Outline: show a function returning an h1; show a class with render() returning an h1; note functions are the React 19 default. Red flag: offering arrow vs function declaration as the two ways, or omitting render().

React & Next.js2 min read

Explain props in React and how parent components pass data to children

Define props as the single object argument; show destructuring; stress immutability and downward flow; note defaults. Your grasp of props as the read-only, one-way parent-to-child interface.

React & Next.js2 min read

Accessible React Forms: Labels, Focus, and Errors

Accessible React forms need real labels, keyboard focus, and error announcements, not just ARIA. Screen reader users must perceive inputs and validation without visual cues. The common footgun is placeholder text or divs instead of label elements with htmlFor.

React & Next.js2 min read

BrowserRouter: Real URLs in React SPAs

BrowserRouter turns the address bar into a client-side navigation system, using real URLs without reloads. It is the default choice for SPAs that need shareable links.

React & Next.js2 min read

BEM: Self-Documenting CSS Class Names

BEM turns classes into a mini filesystem: Block__Element--Modifier. It prevents CSS collisions in large React codebases where many teams share a global stylesheet. The footgun is turning every nested tag into an element and creating comically long names.

React & Next.js2 min read

Rules of Hooks: Call Order Is Sacred

Hook calls must keep the same order every render because React maps them to state by array index. Only call hooks at the top level of React functions. Break the order and React desyncs, producing stale state or crashes.

Product Strategy2 min read

KPIs for a new registration form and technical instrumentation

Tests pairing outcomes with instrumentation. Pick a conversion KPI and a field-level friction KPI, then explain client-side events correlated with server logs while scrubbing PII. Red flag: relying solely on frontend analytics or vanity metrics.

Growth & Experimentation2 min read

How would you implement a timezone-safe, tamper-proof offer countdown?

Tests distrust of the client and server-side UTC enforcement. Outline: server owns canonical end time; client syncs clock offset to render remaining time; checkout re-validates expiry. Red flag: using local Date.now or localStorage.

Growth & Experimentation2 min read

How would you track a 'Sign Up' button click end-to-end?

It tests your ability to instrument a custom event and validate the pipeline. Attach a gtag listener to the button, fire a sign_up_click event, then confirm the hit in GA4 DebugView or real-time reports.

Design Systems2 min read

How would you structure a flexible Card component API?

Tests composition-over-configuration thinking in design systems. A strong answer uses compound components or slots so consumers reorder or omit title, image, and body freely without prop drilling. Red flag: rigid boolean props that freeze layout order.

Design Systems2 min read

Two strategies to prevent style leakage in reusable components and their trade-offs

This tests style encapsulation in design systems. A strong answer contrasts Shadow DOM, which fully isolates CSS via a shadow root, with scoped naming like BEM or CSS Modules. Red flag: proposing global resets or !important as a solution.

Design Systems2 min read

Implement a typographic scale using design tokens and accessible properties

Token-driven typography and accessibility. Start with base size (14-16px) and ratio token, compute sizes, then bundle font-size with line-height, letter-spacing, weight, and family in composite tokens. Red flag: ignoring line-height, spacing, or composites.

Design Systems2 min read

What are the main benefits of consuming a design system?

Cite tokens for theming, isolated components, live docs, and designer collaboration. whether you see a design system as more than a UI kit and tie tokens to velocity. calling it just a CSS framework and ignoring tokens.

Design Systems2 min read

What is a design system and its primary engineering components?

Tests if you treat design systems as engineering infrastructure, not just UI kits. Strong answers cite reusable coded components, design tokens, documentation, and governance as the core. Red flag: calling it just a component library or style guide.

Design Systems2 min read

Scoped Theming: Local Overrides Without Global Leaks

Scoped theming is sunglasses for a UI subtree: it swaps tokens for one section without touching the global page. Use it for a dark-mode dashboard or white-label widget inside a light app, but avoid deep nesting or you will fight invisible inheritance chains.

Design Systems2 min read

Token Aliasing: Theme by Role, Not Value

Token aliasing names a color by its job, not its hex, so you swap the underlying value per theme. One library supports light mode, dark mode, or multiple brands without code changes. The footgun is deep alias chains that hide which primitive value renders.

Get Frontend bites daily.

Five a day, five minutes, offline. With quizzes so it sticks.

Open testing — you’ll join as an early tester.