TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: If you’ve used both Svelte and React, which is better?

3 pointsby jjdeveloperover 1 year ago
Interest in hearing opinions from people who have used both and why they chose the one they did.

3 comments

andrewfromxover 1 year ago
In React, you typically manage state changes manually using setState or hooks. While libraries like Redux can help with state management, React doesn't provide automatic two-way data binding out of the box like Svelte. Also no virtual DOM with Svelte. Why did I chose one over the other? I didn't. I just worked on various projects over the years and inherited code where someone else made this choice. Which is better? It's like the line from war games, the correct answer is not to play. Just don't use any JS framwork at all. Keep everything server side rendering and minimal JS code only when absolutely necessary.
houseatrielahover 1 year ago
I hit my first roadblock in React -- I had a list of objects each had lists in them (list&lt;Post&gt;, Post has list&lt;Replies&gt;). I wanted the UI to update when a reply is updated. This isn&#x27;t straightforward, <a href="https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;43040721&#x2F;how-to-update-nested-state-properties-in-react" rel="nofollow noreferrer">https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;43040721&#x2F;how-to-update-n...</a>
ttfkamover 1 year ago
I&#x27;ve comments on it, but here goes again. I can&#x27;t at all say Svelte lacks magic, but that magic is focused on eliminating boilerplate, not hiding where everything is coming from and going to.<p>It is jarring at first when you look at your code and say, &quot;Wait, what else do I need to do?&quot; And there&#x27;s nothing left.<p><pre><code> const { count, setCount } = useState(0); </code></pre> in React becomes the following in Svelte.<p><pre><code> let count = 0; </code></pre> There is no more useMemo(…) or useEffect(…). No trying to help junior devs wrap their minds around closure rules just for basic functionality. These &quot;extra&quot; APIs on top of your problem just don&#x27;t exist. There&#x27;s no need for them. State management &quot;just works&quot; by using a store variable like $store instead of a more explicit subscribe callback and then having to remember to set up an event callback to unsubscribe and avoid a resource leak.<p>Vanilla JS libraries typically work out if the box with it without some bespoke wrapper or adapter for your framework. (&quot;bind:this&quot; is really handy.) Web development with 99% less BS. Lets you focus on your problem, not on your framework&#x27;s abstraction leaks.<p>In Svelte, CSS is automatically scoped to your component. No manual shenanigans, weird naming rules, or bespoke CSS generation from JS your dev team have to agree on like what&#x27;s found in React. No giving up and just using inline styles. No hacks.<p>Just make a descriptive class name and write your CSS styles. That&#x27;s it. You&#x27;re done. For that reason, it reduces any desire I have to work with Tailwind, since we don&#x27;t have to worry about style leakage. For pre-made styles, Open Props works better with SvelteKit&#x27;s model.<p>If you like functional programming (like <i>REALLY</i> like it and consider it the &quot;one true way&quot;), React will likely appeal to you more since it puts programmatic logic above all other concerns and really cares about immutability and one-way data binding.<p>For the rest of us who care a little less about (in my opinion illusory) absolute purity and more about getting the job done as quickly as possible, with the least amount of code, and more understandable to newcomers, SvelteKit simply can&#x27;t be beat for developer experience.<p>Under no circumstances would I recommend using React without a metaframework like NextJS. Similar advice for Svelte&#x2F;SvelteKit, though I have used Svelte on its own for trivial, truly single-page view apps&#x2F;pages.<p>For a beginner, no question: Svelte&#x2F;SvelteKit is easier to learn, teach, and become productive with.<p>If you hate HTML and CSS, React is far better at hiding the underlying technologies from view. With Svelte, HTML and CSS are baked in to the developer experience.
评论 #37384664 未加载