Svelte vs ReactJS

Summary

The Svelte vs React argument is straightforward when the project requirements are clearly defined.

Use Svelte for your projects to achieve a smaller bundle size, maintainable code, and exceptional performance without the VDOM. Due to the framework's simplicity, Svelte enables developers to prepare a website faster.

Using React for your projects will make it easier to hire developers. React makes it easy to maintain the stability of your application. An active community of React developers helps resolve doubts and bugs observed during development.

The Svelte community is small, with only 11K developers, compared to more than 287K active React devs. (2022)

ReactJS

React Logo

React is a free and open-source front-end JavaScript library for building user interfaces based on UI components.

Declarative - React makes it painless to create interactive UIs and makes your code more predictable

Component-Based - Build encapsulated components that manage their own stage, then compose them to make complex UIs.

React is a flexible component library that is perfect for state management. Thus, websites and apps that use React components can exchange data without reloading the page. React should be used for user interfaces that require a lot of user interaction.

React corresponds to ‘view’ in the model-view-controller. Thus, managing lower-level algorithms with React is easy, and coding is required only for the interface’s view model. React’s Virtual DOM improves website performance and reduces lags to enhance loading times.

Good parts

  • ReactJS is popular. According to Worldwide developer survey ReactJS is the most used framework among developers (2022) 42.62%
  • Easy scripting. ReactJS offers a free extension, JSX, which simplifies the HTML markup in the library.
  • Modular design. Easy to reuse the same components and assets without disturbing other components
  • Easy to start coding with React, and a fantastic community
  • One-way data binding
  • Bundle size 42Kb

Disadvantages

  • SEO. Unless you use server-side rendering before sending files to the user, there won't be much content for Search Engines to crawl.
  • The architecture and learning process might become much harder to grasp for more extensive applications. Also, developers must learn the hooks concepts and state management.

Who uses ReactJS

Highly successful organisations like Facebook, Instagram, Salesforce, Shopify, Discord, Skype, and Pinterest use React to develop user interfaces. Due to the availability of many developers globally, companies prefer React to create the front-end part of their websites.

Svelte

Svelte Logo

Svelte is a framework which can be built with SvelteKit, the official app framework from Svelte Team (currently Beta)

Creator Rich Harris:

“It’s a component framework, but it’s also a compiler, and it’s also a library of the things that you need when you’re building an application, and a philosophy of building web apps, I guess.”

Svelte is a radical new approach to building user interfaces. Whereas traditional frameworks like React and Vue do the bulk of their work in the browser, Svelte shifts that work into a compile step that happens when you build your app.

Instead of using techniques like virtual DOM diffing, Svelte writes code that surgically updates the DOM when the state of your app changes.

Good parts

  • Easy to learn. If you know HTML and CSS, you can write Svelte immediately and learn as you go.
  • Svelte is famous for DX advantages.
  • Great performance
  • Reduce code amount used for the same ReactJS vs Svelte components.
  • SEO is supported out of the box
  • Svelte is a newer framework.
  • Bundle size 1.6Kb
  • Svelte’s developers report high levels of satisfaction using Svelte. Many comments about moving from ReactJS to Svelte made work much easier and development faster.

Disadvantages

  • The compiler architecture moves complexity from the runtime and source code to build time and tools. Behind Svelte’s simple APIs sits a beefy compiler. Frontend web development has become very tool-heavy in the web app era. In practice, this adds little cost beyond what developers like myself already pay, but increased build complexity is essential to acknowledge.
  • Svelte is its own language, not plain HTML+CSS+JS - increasing the risks of adoption
  • Young library ecosystem, fewer job opportunities, and fewer devs with knowledge of Svelte. Also, in 2022, this might be less true, as Svelte’s name comes together with React, Angular, Vue and similar.

Who uses Svelte?

Major companies such as Yahoo, Rakuten, Bloomberg, Facebook, Apple, The New York Times, Square, ByteDance, Spotify, Reuters, Ikea, Brave, and others rely on Svelte for their websites. Companies prefer Svelte because it converts the application’s code to ideal JavaScript while coding. Thus, framework abstractions do not hamper the performance of apps written in Svelte.

References

Rethinking Reactivity
Why Svelte?
Svelte VS ReactJS
Remix vs NextJS vs SvelteKit