loading...
Cover image for A nice intro to Svelte Data Fetching

A nice intro to Svelte Data Fetching

alexandrudanpop profile image Alexandru-Dan Pop ・1 min read

Looking at Svelte it really looks promising and I can see why many people will learn it and use it in the future.

I just see a lot of issues that are quirky to deal with in React, like data fetching in components, are solved more elegantly in Svelte 😎.

If you want to learn about all the things you need to handle when doing data fetching in React take a look at:

Correctly handling async/await in React components
Correctly handling async/await in React components - Part 2

Data fetching

Now comparing the React way of doing it to Svelte - I think the Svelte approach is much nicer:

Why you should learn Svelte

You should learn Svelte not because it's the new cool kid around the block, but because it adds new paradigm shifts to frontend development, that can certainly help you:

  1. Less boilerplate code due to handling state and reactivity in an easy way ⭐
  2. Global state management built in ⭐
  3. No Virtual DOM means faster renders due to avoiding not needed CPU cycles ⭐
  4. Heavy lifting done at compile step means smaller bundles and faster code ⭐
  5. Built in auto-scoped CSS in JS and animations ⭐

So it has 5 stars from me, what do you think?

If you like this article, chances are you will also enjoy what I post on Twitter. 🔥

Posted on by:

alexandrudanpop profile

Alexandru-Dan Pop

@alexandrudanpop

I'm a freelance Software Engineer who loves working with Javascript, React and NodeJs. 👨‍💻 I'm also a big Typescript fan! 🚀

Discussion

markdown guide
 

After somewhat messy setup of redux I would say Svelte's state management is a godsend. The only thing is when tech lead don't pick it up, then less companies use it for serious projects, then less serious showcases to convince people to pick it up. Many might think: why should I bother if I can't find a job learning it?

 

We still need to give it some time, but I think it will be a big thing in the future! It has nice things that we miss in React.

 

Yeah... I fell in love with it when I wanted to pick a framework to learn.. but I ended up learning React first in order to be job-ready. Now after building some stuff with React I come back to pick Svelte again and am learning to build sth more serious. Like a market-ready MVP side project.

 

You should check out the excellent RiotJS - it's very similar and predates Svelte by years