DEV Community

Cover image for Svelte vs React: Which framework to learn in 2023?

Svelte vs React: Which framework to learn in 2023?

Mikhail Karan on December 13, 2022

In the web development world, sometimes it can feel like a new frontend framework comes out every day! Most come and go, but one thing is for sure:...
Collapse
 
lexlohr profile image
Alex Lohr

Don't learn one framework, instead learn the concepts and patterns behind all of them – and the differences that can help you choose the right tool for the job.

No framework or library is a silver bullet. But the right choice can save you a lot of hassle.

By the way, svelte is great for smaller apps, but inexplicably doesn't scale too well. Try Solid.js.

Collapse
 
mikehtmlallthethings profile image
Mikhail Karan

I think 1. Learn JavaScript fundamentals really well and then 2. Learn framework fundamentals (any framework)

That will make it easy to switch to whichever one is needed.

Collapse
 
zhoorba profile image
Yehor

Not the first time seeing such an answer, but it is kind of overwhelming without the right knowledge. Would be grateful if you could specify some of the core concepts and patterns that you're talking about

Collapse
 
lexlohr profile image
Alex Lohr

You are right; I reached the same conclusion last Thursday and I'm already on it. The article is actually almost ready, but I want to proof-read it a few times after getting it out of my head, so I'll publish it next week. In it, I elaborate on state, effects, memoization, reactivity and templating.

Thread Thread
 
zhoorba profile image
Yehor

Awesome! Eagerly await for the article 🔥

Thread Thread
 
lexlohr profile image
Alex Lohr
Collapse
 
ivan_jrmc profile image
Ivan Jeremic

Finally someone giving the right answer to beginners.

Collapse
 
slidenerd profile image
slidenerd

what do you mean by " svelte is great for smaller apps, but inexplicably doesn't scale too well. Try Solid.js." why does svelte fail for larger apps? what does solid have that svelte doesnt and more importantly what is your affiliation with solidJS?

Collapse
 
lexlohr profile image
Alex Lohr • Edited

Have a look at this: dev.to/this-is-learning/javascript...

I'm not sure why this is the case - I would submit a PR to Svelte if I knew how to fix this.

Svelte outsourcers a lot of complexity into its wonderful transpiler. Solid only uses its transpilation for efficient templating and re-uses its reactive system for everything else.

And why is it important that I am part of the Solid.js community? I have merely stated an observed fact. You can test it for yourself.

Collapse
 
dan1ve profile image
Daniel Veihelmann • Edited

I learned Svelte before React, and now React feels unnecessarily complex every time I use it 🙈

I sort of disagree with the "React has more libraries" part by the way. You can use any JS library with Svelte.
So phrased differently, you could say "React requires libraries to be wrapped before usage"

Collapse
 
mikehtmlallthethings profile image
Mikhail Karan

Yeah it's always tough for me to go back to a React project after working in Svelte!

Collapse
 
jareechang profile image
Jerry

The trade-off is now you need to maintain a custom svelte-react wrapper.

imo, generally, more code, more problems.

Guess what now you need documentation, tests and more!

Collapse
 
leob profile image
leob • Edited

Great article, well-written ... of course a simple code example like this does not prove that Svelte has all of the imaginable bases (use cases) covered like React has, but I'll just assume it has.

So we can conclude that Svelte has only pros, no cons, compared to React (except that React dominates "the market", but that's not really a characteristic of React itself but more a meta-characteristic).

The only "downside" of Svelte might be - that SolidJS might be even better? :)

Collapse
 
mikehtmlallthethings profile image
Mikhail Karan

Haha, I need to try SolidJS, been hearing great things.

Collapse
 
leob profile image
leob

Yeah, the real competition should be between Svelte and Solid, not between Svelte and React - but we're all "forced" to use React, even though it's inferior in almost all respects, because, well, it's the proverbial 900 pound gorilla in "the market" ... kind of saddens me, but oh well.

Collapse
 
oshox profile image
oshox

SolidJS and/or Marko for 2023. Check out Ryan Carniato on YouTube to find out why.

Collapse
 
mikehtmlallthethings profile image
Mikhail Karan

Interesting I'll for sure check it out!

Collapse
 
oshox profile image
oshox

I should probably also mention that Ryan is active on dev.to

dev.to/ryansolid

Collapse
 
z2lai profile image
z2lai

An effective way to learn something is to compare it to what you already know. Great comparison with React, it gave me a the gist of what Svelte is.

In all my time looking for jobs though, I have not seen a single job that had Svelte written anywhere (Canada). Interesting to see adoption by those big websites though. Excellent article!

Collapse
 
mikehtmlallthethings profile image
Mikhail Karan

It's slowly becoming more propular and easier to adopt. SvelteKit (next.js equivilant) has just been fully released out of beta (v1.0.0) so that should help with adoption.

Collapse
 
bookercodes profile image
Alex Booker

Svelte definitely looks cleaner and the idea of smaller bundles is appealing!

Great post, @mikhailkaran!

Collapse
 
mikehtmlallthethings profile image
Mikhail Karan

Appreciate all the help from you and team on the post!

Collapse
 
yaroslaff profile image
Yaroslav Polyakov

Pleasure, simplicity and beauty are very important.

"Pleasure" is non-technical term, not easy to measure but very important.

Almost 10 years ago I had dilemma, what next modern language to learn: Python vs Ruby.
Then I examined list of popular ruby projects and list of popular python projects. And what I've found:

  • Both languages are popular, both are "good"
  • Almost all ruby projects were related to "work"
  • Python had lot of "work" projects too, but also it had many projects which had no business value, which were written just for fun!

So, I decided Python is more fun to use. And yes, after many years with Python I still think I did right choice. It's pleasure to use Python both for work and for fun. And I work more efficiently when it's pleasure to work.

Also I think Python won this race and now much more popular. Because of "pleasure".

Now, I have little more then "hello world" experience with most popular frameworks and I'm impressed with Svelte and working with it. Clean, simple, easy. This is very important. And I think these defines future.

Collapse
 
horstcredible profile image
Horstcredible

This is actually a really nice comparison.
Good to see that React gets more and more competitors which begin to reach the right level of stability and reliability to be a real competition.

This will lead to massive improvements in the React.js project, too, I can imagine.
I don't think Facebook wants React to be beaten by the new kids on the block and that they will rather choose to improve React to be much better in performance.

Also I wonder what else you could use at the moment as an alternative to React and in which cases?
What's currently good for creating different sized projects?
Small ones -> Svelte, ...?
Mid sized ones?
Enterprise level big ones?

Collapse
 
mikehtmlallthethings profile image
Mikhail Karan

Vue.js is a great alternative that has more and more usage in the real world.

The smaller ones like Solid and Astro are also creeping up.

Collapse
 
heyhadi profile image
Munawirul Hadi

Svelte is way better than react, has less boilerplate, easier to maintain and easier to learn. If I am to build my personal project, Svelte is the way to go for me.

Collapse
 
mikehtmlallthethings profile image
Mikhail Karan

Same.

Collapse
 
mikehtmlallthethings profile image
Mikhail Karan

There is a mistake in the article.

When comparing Svelte vs React I mentioned Svelte has a built in router and that is not true.

Will be doing a minor rewrite of that section shortly.

Sorry everyone!

Collapse
 
_bkeren profile image
''

Your Svelte code breakdown section shows react snippet. Can you fix it?

Collapse
 
mikehtmlallthethings profile image
Mikhail Karan

Great catch, sorry about that.

Just edited it with the right sandbox.

Collapse
 
yuridevat profile image
Julia 👩🏻‍💻 GDE

Thanks for this detailed comparison 🙏

Collapse
 
mikehtmlallthethings profile image
Mikhail Karan

No problem!

Collapse
 
rizmyabdulla profile image
Rizmy Abdulla 🎖️ • Edited

Hey, i'm going to take a look at svelte for my project.

What do you'll recommend for create a school website from react and svelte

Collapse
 
mikehtmlallthethings profile image
Mikhail Karan

The svelte documentation has a great tutorial built in it! svelte.dev/tutorial/basics

If you need something a bit more guided I've created a Svelte for Beginners course on Udemy: udemy.com/course/svelte-for-beginn...

Collapse
 
raddevus profile image
raddevus

That's a great article & now that I've learned quite a bit about React I'm going to take a look at Svelte. Thanks for sharing.

Collapse
 
purva2803 profile image
Purva Rajyaguru

Keep writing 🥳

Collapse
 
mikehtmlallthethings profile image
Mikhail Karan

Will do! 🫡

Collapse
 
sohrab09 profile image
Mohammad Sohrab Hossain

Great Article brother.

Collapse
 
mikehtmlallthethings profile image
Mikhail Karan

Appreciate it Sohrab!

Collapse
 
nafizmahmud_94 profile image
Nafiz Mahmud

Solid.js for me.

Collapse
 
dadegi profile image
Naviganet

But why not Angular? Although its high learning curve, Angular is a real framework and offers all you could need in native way (expecially state management and HTTP methods). IMHO Angular is the only choose in medium/big projects.

Collapse
 
lokaimoma profile image
Kelvin Clark • Edited

I think you're comparing react and svelte kit. Because svelte doesn't have routing baked in by default and svelte on it's own will render on client side, etc. Svelte kit is what adds most of the bells and whistles you were taking about in favor of svelte, just like NextJs for react.

Collapse
 
brense profile image
Rense Bakker

React in the end also uses basic DOM manipulation (if you dive into the framework code). I haven't used Svelte yet, although its something I'm tracking... I'm really not a fan of this weird looking template style comments inside your HTML code... It's seems to me like a step back to the days of ugly PHP template engines. However I'm just one person and unfortunately it seems I'm incapable of convincing people that this is a bad idea :(

Collapse
 
ndaidong profile image
Dong Nguyen

haha, as I remember, before PHP template engine as Smarty, I had to mix HTML and CSS within PHP script files, exactly as same as what React devs have to do today: write HTML and CSS with JS script 😅

Collapse
 
brense profile image
Rense Bakker

Uhm, and with svelte you're not? The difference is, in React you're only writing JavaScript (and jsx) it all follows JavaScript rules, you dont have to learn any weird syntax logic, like with smarty or svelte.

Thread Thread
 
noahlaux profile image
Noah Laux

and with React, to handle state you need the weird hooks which comes with weird rules AND to use them properly without re-rendering mayhem you need to memorize

Thread Thread
 
brense profile image
Rense Bakker

There are a lot of different state management solutions for React. If you dont like what is currently offered, you can easily write your own, its all standard JavaScript. Yes there are some hooks you should probably learn about when you want to properly use React but there's no weird syntax, its all basic JavaScript and JSX.

Collapse
 
laazycmd profile image
Shawn Gestupa

Great article! Svelte was the one that got me into web development, and I was able to slowly get comfortable with learning anything web dev-related because of it.

Correct me if I'm wrong, but I believe Svelte has no built-in routing functionality. Thank you for this article.

Collapse
 
ozzythegiant profile image
Oziel Perez

Svelte. There is no other answer. Svelte returns us to plain JS where we can use any library we want and we are not locked in to whatever is available for a framework. React has to go! It's anti patterns are a cancer on web development.

Collapse
 
biganth profile image
Anthony DeFreitas

Neither. SolidJS is the way.

Collapse
 
olex_green profile image
Olex Tkachuk • Edited

The statment "React requirers third-party libraries and tools like Redux" - is wrong. React has built-in rich state managment - useState, useRedux. react-router and react-dom - are not exactly third-party libs.

In my opinion, Svetle is promising framework, I'd like to try it, but now I'm keen more about Flutter.

Collapse
 
hazadus profile image
Alexander

Nice article, thanks. Now I definitely want to try Svelte, sounds very promising :)

Collapse
 
jwp profile image
John Peters

Thank God, Zuckerbucks has a competitor in the rear view mirror. Not to mention Wasm. React just like the others is opinionated. Ridiculous in this day and age.

Collapse
 
emexrevolarter profile image
Emeka Ndefo

Does Svelte have Module Federation & Library functionalities? For example, you can create functions and import them in any part of your app. Also, your app can be split in Modules that work together.

These are what may attract me to Svelte. I presently enjoy them in React.Js, although with extra customization.

Collapse
 
dahla1973 profile image
Andreas Dahlström

We're developing an app in Sveltekit with great success and by combining with capacitorjs.com/ we have both Android and IOS apps using the same source code (including native features access from Javascript). Very happy so far.

Collapse
 
kevinluo201 profile image
Kevin Luo

Svelte looks so similar to Vue.js. Just use Vue.js

Collapse
 
mikehtmlallthethings profile image
Mikhail Karan

It has some significant benefits over Vue. I love Vue though and still use it on some projects but I pick Svelte more often now because of it's simplicity and speed.

Collapse
 
eerk profile image
eerk

I have always wondered why React insists on using the virtual DOM. Is it really that much faster than good old direct DOM manipulation?

Collapse
 
dbroadhurst profile image
David Broadhurst

To specifically comment on the title of this article, if you intend to get a job / better job then React will provide a lot more opportunities than Svelte.

Collapse
 
mikehtmlallthethings profile image
Mikhail Karan

This is true. At this point it is way more in demand in the job market.

Collapse
 
ozzythegiant profile image
Oziel Perez

Svelte. Just drop React, it's a mess! End of discussion

Collapse
 
mariuszmalek profile image
Mariusz Malek

Vue.js

Collapse
 
danielsharkov profile image
Daniel Scharkov

Svelte itself doesn't come with a build-in router, but you're propably talking here about SvelteKit.
Correct me if I'm wrong.

Great article! 😀

Collapse
 
mikehtmlallthethings profile image
Mikhail Karan

I'll be honest...I screwed up there and confused it with Vue which has a 1st party router (not built-in) that is developed by the creators 😅

Going to post a edit to the article shortly with that.