Published on
· Matt Pocock

Vercel wants you to fetch data like this

This post is auto-generated from a public YouTube video for personal study notes. It is not an endorsement. The transcript is machine-derived and may contain errors; refer to the original video for accuracy.

About this video

In this video, we take a look at the major update to Vercel's hooks for data fetching called useSWR, which is now in version two.

The new useSWR mutation hook allows for updating data on the frontend before receiving word back from the server, making the application feel snappier.

We can also use the new preload function to load data as soon as the JavaScript module comes into scope. The useSWR hook now also includes a newly added isLoading state, which triggers only once when loading data.

The release also improves React 18 support and includes a migration guide for existing useSWR 1.0 users.

While it's difficult to say whether it may replace TanStack Query, useSWR is a great option to consider for data fetching in React-based applications.

Become a TypeScript Wizard with Matt's upcoming TypeScript Course:

Loading transcript…