Skip to main content

Web frontend

The web runs on uncontrolled browsers and networks: HTML parsing, JS execution, style/layout, input, and accessibility. This page uses React + TypeScript as the primary reference (aligned with this docs site and many product stacks); ideas transfer to other frameworks.

Platform layers (in the browser)

LayerFocusNotes
DocumentSemantic HTML, SEO, progressive enhancementStructure before chrome
StyleLayout, theme, responsiveDesign tokens; limit global leakage
BehaviorEvents, state, fetchingValidate API payloads at the edge
AssetsImages, fonts, splittingAVIF/WebP, loading=lazy

React app shape (default)

AreaRole
RoutingURL ↔ views; loaders and error boundaries
ComponentsPresentational vs container; composition over inheritance
StateSeparate server state from UI state
Datafetch / RTK Query / React Query; cache & invalidation

Server state (remote truth): query libraries for stale time, retry, dedupe.
UI state (local UX): useState / small context; avoid global stores by default.

tip

Default data flow: props down, events up; context or light store across trees; global state only when measured need exists.

TypeScript and API edges

  • Validate API responses at the boundary (zod, valibot) before deep trees
  • Explicit prop types; stable list keys
  • Strict tsconfig: strict, add noUncheckedIndexedAccess gradually if needed

Matches architecture · boundaries: do not leak backend DTO shapes into every component.

Performance checklist

ItemPractice
First paintRoute-level code splitting, critical CSS
RenderAvoid needless child re-renders; memo only with profiling
ListsVirtualize very long lists
NetworkCache headers, compression, fewer waterfalls
Imagessrcset, placeholders, prioritize LCP

Measure with Lighthouse and Web Vitals (LCP, INP, CLS); spot-check on real 4G devices.

Accessibility

  • Prefer native controls or complete roles / keyboard / focus
  • Contrast and type scale; respect system settings
  • Forms: associated label, aria-invalid, readable errors
  • Motion: prefers-reduced-motion

Test pyramid (frontend)

LevelToolsTarget
UnitVitest/Jest + RTLPure functions, hooks, small components
IntegrationRTLForms, routing
E2EPlaywrightCritical paths, sampled browsers

Run E2E smoke on PRs, fuller suites on schedule—see CI/CD.

This docs site

Built with Docusaurus + React: MDX as documentation components; i18n splits /docs and /en/docs. Theme or sidebar edits should keep builds and the English mirror in sync.