Frontend Architecture
Overview
Frontend architecture is how you split a UI into components, decide where data lives and how it flows, and control what code ships to the browser and when. Good structure keeps features local, props predictable, and bundles small. Read this when starting a new app, drawing component boundaries, or addressing slow initial loads.
Official sources
Core concepts
- Components compose top-down. A React component is a function returning markup; you nest components and pass data via props, building UI from small reusable pieces (react.dev/learn).
- One-way data flow. Data flows down through props; child components do not mutate parent state directly, which makes data movement easy to trace (react.dev/learn).
- Lifting state up. When two siblings need the same data, move that state to their closest common parent and pass it down, rather than duplicating it (react.dev/learn/sharing-state-between-components).
- Single source of truth. State should not contain redundant or duplicated information; derive values during render instead of storing them (react.dev/learn/choosing-the-state-structure).
- Code-splitting with lazy loading.
lazy defers loading a component's code until it first renders, reducing the initial bundle; it must be paired with <Suspense> (react.dev/reference/react/lazy).
- Rendering / loading patterns. patterns.dev catalogs reusable approaches such as bundle splitting, the PRPL pattern, and import-on-interaction to ship less JavaScript up front (patterns.dev).
Best practices
- Push
'use client' / interactive boundaries as deep into the tree as possible so static parts stay shippable and bundles stay small (react.dev/learn; patterns.dev performance patterns).
- Keep state minimal and derived data computed in render, avoiding state you would have to keep in sync (react.dev/learn/choosing-the-state-structure).
- Split routes and heavy, rarely-used components with
lazy + Suspense so users only download what they need (react.dev/reference/react/lazy).
- Co-locate state with the components that use it, lifting it only as far up as required by shared consumers (react.dev/learn/sharing-state-between-components).
Common pitfalls
- Declaring a
lazy component inside another component → declare it at module level; nesting it resets state on every re-render (react.dev/reference/react/lazy).
- Storing redundant or duplicated state (e.g. a
fullName alongside firstName/lastName) → compute it during render to avoid sync bugs (react.dev/learn/choosing-the-state-structure).
- Prop-drilling shared data through many layers → reconsider component boundaries or use context where appropriate (react.dev/learn/passing-data-deeply-with-context).
Examples
import { lazy, Suspense } from 'react';
// Module-level: code is split and loaded on first render.
const MarkdownPreview = lazy(() => import('./MarkdownPreview.js'));
export default function Editor() {
return (
<Suspense fallback={<Loading />}>
<MarkdownPreview />
</Suspense>
);
}
Further reading
Related skills
- ../state-management — choosing where state lives
- ../rendering-strategies-ssr-csr — where components render
1---2name: frontend-architecture3description: Structuring component boundaries, data flow, and code-splitting in modern frontend apps; consult when designing or refactoring UI architecture.4domain: engineering5category: frontend6tags: [components, data-flow, code-splitting, react, architecture, lazy-loading]7official_sources:8 - https://react.dev/learn9 - https://www.patterns.dev/10 - https://github.com/react/react11verified: 2026-06-1612metadata:13 source: https://skillmd.com/skills/gabriel7silva/frontend-architecture14---1516# Frontend Architecture1718## Overview19Frontend architecture is how you split a UI into components, decide where data lives and how it flows, and control what code ships to the browser and when. Good structure keeps features local, props predictable, and bundles small. Read this when starting a new app, drawing component boundaries, or addressing slow initial loads.2021## Official sources22- Docs: https://react.dev/learn23- Patterns reference: https://www.patterns.dev/24- Repo: https://github.com/react/react2526## Core concepts27- **Components compose top-down.** A React component is a function returning markup; you nest components and pass data via props, building UI from small reusable pieces (react.dev/learn).28- **One-way data flow.** Data flows down through props; child components do not mutate parent state directly, which makes data movement easy to trace (react.dev/learn).29- **Lifting state up.** When two siblings need the same data, move that state to their closest common parent and pass it down, rather than duplicating it (react.dev/learn/sharing-state-between-components).30- **Single source of truth.** State should not contain redundant or duplicated information; derive values during render instead of storing them (react.dev/learn/choosing-the-state-structure).31- **Code-splitting with lazy loading.** `lazy` defers loading a component's code until it first renders, reducing the initial bundle; it must be paired with `<Suspense>` (react.dev/reference/react/lazy).32- **Rendering / loading patterns.** patterns.dev catalogs reusable approaches such as bundle splitting, the PRPL pattern, and import-on-interaction to ship less JavaScript up front (patterns.dev).3334## Best practices35- Push `'use client'` / interactive boundaries as deep into the tree as possible so static parts stay shippable and bundles stay small (react.dev/learn; patterns.dev performance patterns).36- Keep state minimal and derived data computed in render, avoiding state you would have to keep in sync (react.dev/learn/choosing-the-state-structure).37- Split routes and heavy, rarely-used components with `lazy` + `Suspense` so users only download what they need (react.dev/reference/react/lazy).38- Co-locate state with the components that use it, lifting it only as far up as required by shared consumers (react.dev/learn/sharing-state-between-components).3940## Common pitfalls41- Declaring a `lazy` component inside another component → declare it at module level; nesting it resets state on every re-render (react.dev/reference/react/lazy).42- Storing redundant or duplicated state (e.g. a `fullName` alongside `firstName`/`lastName`) → compute it during render to avoid sync bugs (react.dev/learn/choosing-the-state-structure).43- Prop-drilling shared data through many layers → reconsider component boundaries or use context where appropriate (react.dev/learn/passing-data-deeply-with-context).4445## Examples46```jsx47import { lazy, Suspense } from 'react';4849// Module-level: code is split and loaded on first render.50const MarkdownPreview = lazy(() => import('./MarkdownPreview.js'));5152export default function Editor() {53 return (54 <Suspense fallback={<Loading />}>55 <MarkdownPreview />56 </Suspense>57 );58}59```6061## Further reading62- https://react.dev/learn/thinking-in-react — deriving component structure from a mockup63- https://www.patterns.dev/ — rendering, design, and performance patterns6465## Related skills66- ../state-management — choosing where state lives67- ../rendering-strategies-ssr-csr — where components render