Library
Data FetchingSWR
Data fetching with stale-while-revalidate semantics and a small API surface.
UnverifiedActive
Unverified
Compatibility has not been verified yet in the PreactHub catalog.
Packageswr
npm install swrimport useSWR from "swr"; const fetcher = (url: string) => fetch(url).then((res) => res.json()); export function User() { const { data } = useSWR("/api/user", fetcher); return <pre>{JSON.stringify(data, null, 2)}</pre>;}Introduction
SWR stays appealing when you want data fetching with a smaller mental model than larger query frameworks.
Preact configuration
Typically used via `preact/compat` when integrated into Preact applications.
SSR notes
SSR behavior should be tested in the exact renderer and hydration strategy you use.
Islands notes
Useful for isolated widgets that fetch server state after hydration.