SWR
ELI5 — The Vibe Check
SWR stands for 'stale-while-revalidate' and it's Vercel's answer to data fetching. Show the cached (stale) data immediately, then quietly fetch fresh data in the background. Users see instant results while the truth catches up. Sneaky and brilliant.
Real Talk
SWR is a React hooks library by Vercel for data fetching that implements the stale-while-revalidate HTTP caching strategy. It returns cached data first, then revalidates with a fetch request, providing instant UI updates with eventual consistency.
Show Me The Code
const { data, error } = useSWR('/api/user', fetcher);
When You'll Hear This
"SWR is simpler than React Query if you don't need mutations" / "The stale-while-revalidate pattern makes everything feel instant"
Related Terms
Optimistic UI
Optimistic UI assumes your API call will succeed and updates the UI immediately. Liked a post? Heart goes red instantly.
React Query
React Query takes all that messy useEffect-fetch-loading-error-state code and replaces it with one beautiful hook.
TanStack
TanStack is Tanner Linsley's empire of framework-agnostic tools.