flâneur — a map of the web's best reading

Usage with Next.js – SWR

swr.vercel.app · 956 words · saved by 1 readers

SWR is a React Hooks library for data fetching. SWR first returns the data from cache (stale), then sends the fetch request (revalidate), and finally comes with the up-to-date data again.

--- title: Usage with Next.js type: integration summary: Integrate SWR with Next.js for server-side rendering and static generation. prerequisites: - /docs/getting-started related: - /docs/prefetching - /docs/advanced/cache --- # Usage with Next.js ## App Router ### Server Components In Next.js App Router, all components are React Server Components (RSC) by default. **You can import SWRConfig and the key serialization APIs from SWR in RSC.** ```tsx filename="app/page.tsx" copy import { unstable_serialize } from 'swr' // ✅ Available in server components import { unstable_serialize as infinite_u

Explore this link on the map →

related reading