DEV Community

Cover image for How to use recoil effects_unstable for loading data from API.
Next Dev
Next Dev

Posted on

How to use recoil effects_unstable for loading data from API.

Welcome friends 👋, to this new blog post where you will learn how to use effects_unstable for fetching the data from an API.

For people who know Hindi:

In this blog, I will use this API — https://jsonplaceholder.typicode.com/todos

🤔Situation

Suppose I have a website for making todos where I want to load the todos from an API. So, how will I do it with recoil?

Moreover, your project manager gave you this project which uses Nextjs as its framework and has made these files before 👇

atoms/atoms.ts


Index.ts file

🥳Solution to load the data

we have two methods

Method 1️⃣— Effects_unstable

Method 2️⃣— Effects_unstable

⚠️Concerns

If you are using frameworks like nextjs then you need to know something unique and that is that recoil loads the data by serverside rendering which makes the website load slow.

For any questions, feel free to ask here 👇
Join the Next Dev Discord Server!

Discussion (0)