releases.shpreview
Vercel/SWR/1.2.1

1.2.1

February 2, 2022SWRView original ↗
$npx -y @buildinternet/releases show rel_uv1bUxv5j02j2c2CRDjgh

Highlights of This Release

shouldRetryOnError accepts a function

Previously shouldRetryOnError is either true or false. Now it accepts a function that conditionally determines if SWR should retry. Here's a simple example:

const fetcher = url => fetch(url).then(res => {
  // Fetcher throws if the response code is not 2xx.
  if (!res.ok) throw res
  return res.json()
})

useSWR(key, fetcher, {
  shouldRetryOnError: (error) => {
    // We skip retrying if the API is returning 404:
    if (error.status === 404) return false
    return true
  }
})

Thanks to @sairajchouhan for contributing!

What's Changed

New Contributors

Full Changelog: https://github.com/vercel/swr/compare/1.2.0...1.2.1

Fetched April 18, 2026

1.2.1 — SWR — releases.sh