6 ms·
After 7 Years of React.js Love,I tried Svelte and I have to admit Its Awesome
* Pros for svelte
- No Virtual-DOM, so zero tension for immutability and no re-rendering chaos
- Svelte inbuilt store is Awesome!, No need to add Redux every time and Svelte store and $ operator are also reactive so data change is good enough for re-rendering component
- There is no hooks, so It is very easy to separate data layer from component. In react if there is business logic in Hooks then often It is hard to access that from pure function or Utils.
- Web Components!!!, If you have to built developing atomic ui-libs, which is became necessary for big projects then Svelte is very good option. Svelte has inbuilt support to export web-components which can run in any browser without any framework and good thing is svelte is just compiler so it is not shipping its own code and Vite will export only necessary code which is required for running web-component unlike react where each library must require react as a dependency.
- ShadowDOM is also good, css-modules are not required
- React.js with nextjs is almost similar as svelte-kit. Nextjs may have better features, but Svelte-kit is also growing.
* Cons for Svelte
- If you are not using tailwindcss then you are going to miss passing className prop from parent to child in svelte
- Reactjs has better Community and IDE Support, although my Neovim setup work like charm for Svelte, I still think react will be better for this case
- govih36905 4y agoYeah, Svelte is Good. if community accepts it, It can be a good alternative for ReactJs
- anujkosambi 4y agoAgree!
- make_it_sure 4y agoTry Vue 3 with script setup.
- anujkosambi 4y agoSure, I will, I know they out performed in benchmark but vue3 has web-component support?
- logicalmonster 4y agoI don't want to mindlessly just engage in a 2-minutes-of-hate here, but I absolutely despise that React.js has become the standard in so many companies without them really without examining the alternatives. React.js isn't particularly fast, organized well, or pleasant to work in. The amount of hoops you have to jump through to solve what should often be simple problems is a sick joke on the industry. Any company that adopts Svelte (or other better-than-react alternatives like Mithril.js) will run circles around their competitors.
- Raed667 4y agobeing too early and being wrong is the same thing. even if svelte is better than react (which i'm not conceding yet), the tooling and resources around react are just unmatched. You'd loose so much velocity and/or capability by doing Svelte that you wont be running at all
- anujkosambi 4y agoMay be, React itself go through lots of transitions like, class-components to functional to hooks. Svelte is in early stage, so I am sure there will be changes in svelte as well. And I don't care about performance that much because Browsers and devices always getting better. But Having said that, React's DOM thing always add constraints, like you can only use react supported ui-lib because everything should be in react's tree. Pure HTML and web-components library is very hard to handle with react.
- logicalmonster 4y ago> the tooling and resources around react are just unmatched This is a fair point to bring up and might be the main advantage of React at this point. But as a counterpoint to that, part of the reason that the ecosystem around React is so well-developed is that React itself (in its specific role as a sort of view layer) has like 80,000 libraries and design patterns for lots of necessary tasks like state management. And because React has been around so long, many of these resources and tutorials are out of date or otherwise questionable. Whereas going into something like Svelte, you know that almost certainly you're going to use the built in stores and it's likely going to work perfectly for the overwhelming majority of common use cases. Does it really matter if the Svelte ecosystem is smaller and less developed if the right way to proceed in virtually any project is much clearer? React is certainly "safer" in a sense, you're never going to get in trouble with your boss for choosing React, just about anything that you'll ever want to build with React has been proven as workable, you'll always have 18 dozen libraries to solve just about any problem, and you'll always be able to easily hire a pile of developers when needed. I don't know if there's an objective right answer because every situation is unique and we're sort of dealing with an opinion, but I know which way would increase (this) developer's happiness level.
- bit-mask 4y agoYou can pass class names to child components in Svelte if you bind the child component's props with restProps: https://svelte.dev/repl/c16aa7a6ef714067af6f5eee0a0f453c?version=3.29.0 https://svelte.dev/repl/c16aa7a6ef714067af6f5eee0a0f453c?ver...
- anujkosambi 4y agoYes, I know that, but I think you have to use :global operator and combining it with parent scope class, which is extra steps in Svelte
- deleted 4y ago[deleted]