DEV Community

Cover image for What you prefer svelte or react?
Taimoor Sattar
Taimoor Sattar

Posted on

What you prefer svelte or react?

Svelte is getting popular nowadays, as it provides a small bundle size. But svelte is not popular as compare to react as the jobs posting favor mostly react. Moreover, Gatsby and Next.js are built over React.

It is hard to pick between these two, what is your thought on that? Is it good for a personal project?

Oldest comments (30)

Collapse
 
rhymes profile image
rhymes

Svelte seems very easy and self contained. It seems to be created with the idea of lowering complexity and it compiles to code that doesn't require a runtime. Maybe that's enough to give it ago!

This might help:

Collapse
 
itsjzt profile image
Saurabh Sharma

I prefer svelte but use react for now.

Collapse
 
jonrandy profile image
Jon Randy ๐ŸŽ–๏ธ
Collapse
 
jerliyah profile image
Jerliyah

Svelte!

Collapse
 
cubiclebuddha profile image
Cubicle Buddha

Yea without TypeScript support I wot be picking it up for anything other than hobby projects. Side note: since TS doesnโ€™t lint html files itโ€™s unclear when if ever it will support Svelte.

Collapse
 
bscott profile image
Brian Scott
Collapse
 
ahferroin7 profile image
Austin S. Hemmelgarn

Personally, I prefer neither, but I guess I'm a bit old fashioned by 'modern' web developer standards (I don't use TypeScript either, and ironically have yet to deal with a bug in my code that would have been caught by TypeScript).

Honestly, my thoughts barring that perspective are:

  • If you're just starting out, use neither. In fact, stay away from full app frameworks completely, and ideally away from stuff like jQuery too. Make sure you actually understand how JavaScript works and how the web API's work first, then start looking at stuff that abstracts that away, and you'll end up a much better developer in the long run. I can't count the number of bugs I've seen in software (not just web apps, but software in general) that got introduced because someone had no idea how the underlying platform actually worked.
  • Beyond that, the choice for me would come down to whether I'm doing something that truly needs React. Svelte is smaller, faster, and generally easier to work with with other frameworks than React is, so I'd pick it in preference to React in almost all cases I could.
Collapse
 
juancarlospaco profile image
Juan Carlos

Between Svelte and React, then Svelte.
But I actually use Nim instead anyway.

Collapse
 
hexrcs profile image
Xiaoru Li

Nim, the system language? I'm tempted to learn it but how is it related to UI development?

Collapse
 
juancarlospaco profile image
Juan Carlos

Compiles to JS/WASM, is similar to Svelte. But Templates/Macros/Types โค๏ธ

Thread Thread
 
hexrcs profile image
Xiaoru Li • Edited

Cool, saw the Nim Website Creator project on your GH, looks pretty neat! One of the reasons that I want to learn Nim is that the compiler spits out C code, which sounds amazing for portability.

Collapse
 
taimoorsattar7 profile image
Taimoor Sattar

Svelte Docs has something hard to understand. No clear writing about dynamic pages in svelte. or create a blog page etc.

Collapse
 
v0idifier profile image
void

one point I see that no one is making is performance. React is stupidly slow (any react app on my computer is slow). Svelte is really fast. And it's simpler to code with it.

Collapse
 
taimoorsattar7 profile image
Taimoor Sattar

It has good performance and also small in size; but limited in docs. Gatsby and Next.js are built on react; it is easy to create blog and website. But in svelte, creating dynamic pages for blog post is quite difficult task.

Collapse
 
v0idifier profile image
void

where's the lack of docs on svelte? it has plenty of docs in many different forms. also, you're not supposed to create dynamic pages for a blog. Use Jekyll, ffs.

Thread Thread
 
taimoorsattar7 profile image
Taimoor Sattar

Svelte Docs is good; I mean the stuff like Graphql, typescript is the future improvement of svelte.

Thread Thread
 
v0idifier profile image
void

well, after using graphql a lot, I hate the ecosystem. it's not flexible at all. I'm talking about the official Apollo things. the docs suck. and about typescript, it's a valid point although I don't use it.

Thread Thread
 
csaltos profile image
Carlos Saltos

Svelte supports TypeScripts since months already.

GraphQL can be useful when you donโ€™t have a solid backend service but otherwise just create an endpoint with what you need to request and thatโ€™s it ... you can even choose the language for the backend API server: Javascript, PHP, C#, Rust, Scala, whatever you like the most

Collapse
 
fuksito profile image
Vitaliy Yanchuk

Don't see any reason why I would need to switch from React to some other framework like Vue or Svetle

Collapse
 
csaltos profile image
Carlos Saltos

That makes me remember my grandmother when I changed her computer Windows 95 to Linux ... she asked: why ?

Collapse
 
jonrandy profile image
Jon Randy ๐ŸŽ–๏ธ

Totally agree. JSX makes me want to vomit every time I see it

Collapse
 
rdazvd profile image
Rafael de Azevedo • Edited

Svelte has conventions that can be considered a bit idiosyncratic, but are justified by its "keep it simple" philosophy. It is indeed comparatively performant (even though it is only significant in edge cases such as JS apps that are intensively reactive, targeted at low latency networks or embedded devices). Because Svelte's "compile step" strategy has generated a lot of discussion, it might influence future changes in how other view libraries (including React) deal with DOM manipulation.

The biggest downside of Svelte is that it lacks maturity. But I like its approach very much, and hope the industry sets a special place for it in the future.

PS: as a reinforcement of a point present in other replies to this post, I'd like to stress that if you are an aspiring developer, you are better off not getting caught up with questions of this sort. Ideally, people just starting out concentrate their efforts in becoming familiarized with core Web technologies (the HTML/CSS/JS triumvirate) and how they relate to abstractions such as Svelte or React

Collapse
 
amycheng profile image
Amy Cheng

Svelte is great for personal projects! I find it was easier to get up and running with Svelte than it was with React. However, Svelte might not scale well, if only because React has better tooling. React has things like Storybook, Redux. It plays well with GraphQL and Styled components. Those tools help solve problems like managing a large UI library and data flows. Svelte just doesn't have those tools (yet).

Collapse
 
gaui profile image
Gudjon

I prefer React. Svelte reminds me so much of Vue. The semantics are similar. But this HTML templating syntax is horrendous and gives me nightmares from AngularJS.

Collapse
 
blindfish3 profile image
Ben Calder

Svelte! It's looking pretty good in terms of bundle size and performance; but I'm also really enjoying the experience working with it (despite my current editor not doing too well with syntax highlighting etc). It's just so straightforward to use:

  • minimal boilerplate
  • I much prefer the approach to defining HTML output
  • it should be really easy to onboard junior devs who will already be familiar with using HTML; and <script> and <style> tags :D
  • it provides some really useful optional functionality - e.g. transitions; window events (scroll) etc.

At the moment it's still rather young; so the only downside is persuading colleagues that it's a better choice than React.

Collapse
 
wademartin profile image
Wade

I've used both and Svelte definitely is easier to learn and has a more enjoyable dev experience, from my perspective as someone quite young in their dev career. I also really like a lot of the inbuilt functionality that svelte has such as transitions, window bindings, reactive declarations and reactive statements. If I had just learned HTML/CSS/JS and was looking to learn my first framework, between react and svelte it would be svelte.