Sep 8, 2023

How Svelte fundamentally differs from React

Svelte framework differs from React in the most fundamental way because it does not use virtual DOM and moves as much processing as possible to the server.

How Svelte fundamentally differs from React

Svelte is gaining popularity in the already crowded landscape of front end frameworks. Its sleek design and efficient performance make it a compelling choice for developers looking to build modern web applications. React appears to be the closest and by far the biggest competitor to Svelte and developers often wonder what are the key differences between Svelte and React.

Svelte's philosophy of moving everything to server and to build time

Svelte differs from most other framework in very key aspect. It moves as much work as possible to the server and then sends the final generated HTML to the user's browser. Not just that but it tries to move as much work as possible to the build process itself. Frameworks like React on other hand take a different approach. They send the entire app to the browser and then let the browser do most of the work.

This is the reason why React ends up relying heavily on concept of Virtual DOM but Svelte does not need any such abstraction.

Svelte keeps things close to traditional web apis

One big criticism of frameworks like React has been that they are too complex to learn and introduce very hard to graph concepts like virtual dom, hooks, state variables and such. Granted all this makes application developer simpler but without a coherent API soon these things go out of hand.

Svelte on other hand tries to stay close to the traditional model of web development where you mostly use your standard web apis, css and such. There is no virtual dom, there are no lifecycle hooks to worry about.

Is Svelte as expressive as React ?

One question I get asked often is can I do everything using Svelte that I can do with React. The answer is both yes and no. Svelte is a fairly powerful framework and does not have any inherent weaknesses compared to React. This means it can be used to build complex web applications just like react. However, you might run into issues as you start searching for third party modules. Given that react has been around for years it has much larger community support and third party libraries which are missing for Svelte.

Should I chose Svelte ?

Remember that no one ever got fired for using React. People might question your choice more often if you pick Svelte simply because it has not yet reached the level of popularity that React or Angular enjoys. That does not mean you should completely ignore it either. My recommendation is to use it for your smaller projects first and then build competence around it.

Continue Reading