Packages

swr

2.5.1 · 12 Aug 2026MIT28.9M / weekRepositoryHomepagenpmAtom feed

Your version

1.1.1

10 Dec 2021Where it was published

1.3.0 is the newest release of 1.x.

In short

1 new2 fixed1 internal

Release note

Highlights of This Release

Dynamic refreshInterval

You can now pass a function as refreshInterval, to dynamically return the interval (in millisecond) til the next request, based on the current data:

useSWR('key', fetcher, {
  refreshInterval: function (data: Data | undefined) {
    if (!data) return 3000 // Initial request 
    return data.next_update
  }
})

If return 0, polling will be stopped.

What's Changed

  • refreshInterval as a function

  • If newData is deeply to the latest state, broadcast the latest state

  • Return undefined data if key's falsy under suspense mode

A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.