Skip to main content

Variable: useSWR

const useSWR: SWRHook

Defined in: node_modules/swr/dist/index/index.d.ts:28

A hook to fetch data.

https://swr.vercel.app

Example

import useSWR from 'swr'
function Profile() {
const { data, error, isLoading } = useSWR('/api/user', fetcher)
if (error) return <div>failed to load</div>
if (isLoading) return <div>loading...</div>
return <div>hello {data.name}!</div>
}