How do you fetch and manage data in a React app?

You could try using fetch directly and work with built-in React hooks like `useEffect`.

Then what if you want to:

  • 📋 cache data between components
  • 🌎 sync data between browsers
  • 🔄 check for new updates
  • 💨 add optimistic UI support

Then you have to add more custom logic to handle these cases.

What if there's a library that does all of these(and more) for you. That's SWR.

Have a look at the following example. That's what we are building in this lesson.

Play Now