Swr Versions Save

React Hooks for Data Fetching

v2.1.0

1 year ago

Feature

Checkout subscription docs and useSWRInfinite parallel fetching docs for more details

Patches

Misc

New Contributors

Full Changelog: https://github.com/vercel/swr/compare/v2.0.4...v2.1.0

v2.0.4

1 year ago

Patches

Misc

New Contributors

Full Changelog: https://github.com/vercel/swr/compare/v2.0.3...v2.0.4

v2.0.3

1 year ago

Patches

Chores

New Contributors

Full Changelog: https://github.com/vercel/swr/compare/v2.0.2...v2.0.3

v2.0.2

1 year ago

v2.0.1

1 year ago

In this patch release, we majorly improved typing support and SWR can infer the types based on the configuration.

  • When the suspense option is true, the returned data will exclude undefined and the isLoading will always be false.
  • When the fallbackData option is provided, the returned data will be the same type of fallbackData, and the isLoading will always be false.

Here's a demo for it:

https://user-images.githubusercontent.com/4800338/213288879-ffbeeeb5-aca5-4a65-8229-69fbf9b0bf70.mp4

What's Changed

New Contributors

Full Changelog: https://github.com/vercel/swr/compare/2.0.0...v2.0.1

2.0.0

1 year ago

Announcing SWR 2.0

We are excited to announce the release of SWR 2.0! The new version comes with a lot of improvements:

  • New useSWRMutation hook
  • Enhanced mutation and optimistic UI capabilities
  • SWR DevTools
  • Preload resource
  • Improved React 18 support

And more!

Read our blog post and migration guide: https://swr.vercel.app/blog/swr-v2

What's Changed

New Contributors

Full Changelog: https://github.com/vercel/swr/compare/1.2.2...2.0.0

2.0.0-rc.3

1 year ago

What's Changed

Full Changelog: https://github.com/vercel/swr/compare/2.0.0-rc.1...2.0.0-rc.3

2.0.0-rc.1

1 year ago

The last RC before SWR 2.0. This release includes several small fixes with one breaking change.

Breaking

In this release, we are dropping IE 11 support, and using ES2018 as the build target. However, when using SWR in a framework or using a bundler (esbuild, Webpack, etc.), you can still target ES5 or using a browserlist configuration to customize this.

The benefit of this change is, we can now use faster native APIs to make SWR more performant, instead of using old alternatives. A benchmark shows a 4.7x speed improvement of the useSWR() function call during SSR, when we change Object.assign({}, a, b) to { ...a, ...b }.

Details can be found in #2249.

What's Changed

New Contributors

Full Changelog: https://github.com/vercel/swr/compare/2.0.0-rc.0...2.0.0-rc.1

2.0.0-rc.0

1 year ago

The SWR 2.0 release candidate. This RC has one breaking change, a new option for mutation APIs, and some bug fixes & improvements.

Highlights & Breakings

A failed mutation will not cause useSWR's error to be updated:

const { error, mutate } = useSWR('/api/user', getUser)

return <button onClick={async () => {
  try {
    await mutate(updateUser)
  } catch (mutationError) {
    // `mutationError` will not cause `error` to be updated.
  }
}}>Update User</button>

In 2.0, with the example above, error will only be coming from getUser and will be shared across all useSWR('/api/user') hooks. And mutation errors (mutationError) will be coming from mutations like updateUser calls, they will be separated from fetcher errors.

There is also a new option throwOnError for useSWRMutation to disable the default throwing behavior of trigger:

const { trigger } = useSWRMutation('/api/user', updateUser)

try {
  await trigger()
} catch (err) {
  // ... it throws when failed to trigger the mutation so you can
  // easily change the flow here
}
const { trigger, error } = useSWRMutation('/api/user', updateUser, {
  throwOnError: false
})

// You don't need to try-catch here, you can instead handle errors
// on the component level in a declarative way
await trigger()

Read more about this change in #2182.

What's Changed

Full Changelog: https://github.com/vercel/swr/compare/2.0.0-beta.7...2.0.0-rc.0

2.0.0-beta.7

1 year ago

Most changes in this release are maintenance related, as we are finalizing everything for the upcoming 2.0 stable version.

What's Changed

New Contributors

Full Changelog: https://github.com/vercel/swr/compare/2.0.0-beta.6...2.0.0-beta.7