Saman
  • Projects
  • Gallery
  • Blog
  • Resume
GitHub

Build experiments. Learn constantly. Ship iteratively.

Next.jsTypeScriptGSAPThree.jsLenisTailwind
  • GitHub
  • LinkedIn
  • Instagram
  • Saman Sahraei
  • Projects
  • Resume
  • Blog
  • Gallery

© 2026 Saman Sahraei

←All notes
Published October 3, 20256 min readSaman Sahraei

React Query Patterns for Live Portfolio Demos

Stale times, refetch intervals, and optimistic UI for dashboards that look alive without pretending to be production infrastructure.

React QueryNext.jsDX
React Query Patterns for Live Portfolio Demos by Saman Sahraei

Portfolio demos sit in an awkward middle ground: they must feel realtime, but they should not hammer a mock API like a stress test. React Query is the right layer because it separates server state from UI state while giving you precise control over freshness.

queryOptions over useEffect

Every demo fetch is defined once with queryOptions — typed query keys, Zod-validated responses, and explicit staleTime. Components stay dumb; the cache owns retry, dedupe, and background refresh.

  • ◆Short staleTime + refetchInterval for monitoring-style panels
  • ◆Long staleTime for static geospatial payloads
  • ◆Route-level loading.tsx shells so navigation feels immediate
  • ◆Dynamic imports for heavy chart and map chunks

The result is a demo that reads as live telemetry while remaining cheap to run on a static deployment.

More notes

December 8, 2025

Real-Time Frontend Architecture

How to separate event throughput from render throughput using normalization, buffering, batch processing, and selective subscriptions in high-frequency dashboards.

November 12, 2025

Tile-Based Caching for Interactive Maps

How square tile keys, spatial caches, and zoom-aware fetching keep dense vendor maps responsive without blocking the UI thread.

August 21, 2025

GPU-Friendly Overlays on Top of MapLibre

Synchronising Three.js with MapLibre, instancing markers, and keeping 60 FPS when the camera moves.