Vue vs React vs… Svelte?!

Rosie Faulkner
19 min readFeb 10, 2023

--

If you value community and ecosystem, React or Vue may be a good choice, while if you value performance and abstraction, Svelte may be a better choice.

Disclaimer: You’ll hear me often refer to React as a framework, rather than a library. React is often referred to as a “framework” because it provides a complete solution for building web applications, similar to what frameworks such as Angular and Vue.js offer. It provides a set of abstractions, tools, and conventions that make it easier to build and manage complex applications.

However, React is technically a library rather than a framework, because it focuses on a specific aspect of web development (the view layer) and leaves other parts of the application, such as routing and state management, to be handled by other libraries or custom code.

This distinction is somewhat subjective and often depends on how React is being used in a particular application. Some developers may consider React a framework because it provides a comprehensive set of tools for building web applications, while others may consider it a library because it focuses on a specific aspect of the application and leaves other aspects to be handled by other libraries or custom code.

The distinction between a framework and a library is not always clear-cut, and what matters most is whether the tools and abstractions provided by React help you build the applications you need in an efficient and effective way.

Now…on to our regularly scheduled programming

The choice between Vue.js and React.js often comes down to personal preference and the specific needs of a project. Both are popular JavaScript libraries for building user interfaces, and both have their own strengths and weaknesses.

Here are some reasons why someone might choose Vue.js over React.js:

  1. Ease of learning: Vue.js has a simpler learning curve compared to React.js, making it easier for developers who are new to JavaScript frameworks to pick up.
  2. Performance: Vue.js is known for its fast performance and small size, which makes it suitable for building lightweight and fast-loading applications.
  3. Template-based syntax: Vue.js uses a template-based syntax, which can be familiar and intuitive for developers who have worked with HTML templates before.
  4. Reactive data binding: Vue.js uses a reactive data binding system that makes it easier to handle changes to the data in your application.

On the other hand, here are some reasons why someone might choose React.js:

  1. Popularity and community support: React.js is one of the most popular JavaScript frameworks, and has a large and active community of developers who contribute to its development and offer support to other users.
  2. Scalability: React.js is highly scalable, making it suitable for building large-scale applications that need to handle a lot of data and user interactions.
  3. Virtual DOM: React.js uses a virtual DOM, which allows for efficient updates and renderings of components.
  4. Integrations: React.js can be easily integrated with other tools and technologies, making it a versatile choice for building a wide range of applications.

Ultimately, the choice between Vue.js and React.js will depend on the specific needs and goals of your project, as well as the preferences and skills of your development team.

Here are some of the best reasons for using Svelte:

  1. Performance: Svelte generates highly optimized code, making it well-suited for high-performance applications. This can result in faster load times, improved runtime performance, and a better user experience.
  2. Abstraction: Svelte provides a high level of abstraction, making it easier to build and maintain your application as it grows. This means that you can write more concise and maintainable code, and avoid repetitive or error-prone tasks.
  3. Code size: Svelte generates smaller code compared to other frameworks, making it faster to download and run in the browser. This can result in a faster and more responsive application.
  4. No virtual DOM: Unlike other frameworks, Svelte does not use a virtual DOM. This means that Svelte is able to update the DOM more efficiently, which can result in improved performance in certain use cases.
  5. Productivity: Svelte provides a faster development experience and helps you write less code compared to other frameworks, making it easier to build and maintain your application.
  6. Learning curve: Svelte has a relatively simple and straightforward API, making it easy to learn and use. This can result in a faster development time and reduced costs for your project.
  7. Flexibility: Svelte is highly flexible and can be used in a variety of different use cases, from small single-page applications to large-scale enterprise systems.

Overall, Svelte is well-suited for developers who value performance, abstraction, and productivity. It is a good choice for building high-performance, maintainable, and scalable applications.

Image credit: Sunil Sandhu 11/21/2019

How can Svelte be fast when it doesn’t use a virtual DOM?

Svelte is a JavaScript framework for building user interfaces. Unlike other popular front-end frameworks, such as React and Angular, Svelte takes a different approach to building web applications.

With Svelte, instead of running your code in the browser and using a virtual DOM to update the UI, the framework generates efficient JavaScript code at build time, so that the code that runs in the browser is optimized for your specific application. This means that with Svelte, there’s no runtime overhead, and you get the benefits of a framework without sacrificing performance.

Here are some reasons why you might choose to use Svelte:

  1. Smaller bundle size: Svelte’s approach to building applications results in smaller bundle sizes, which can lead to faster load times and better performance for your users.
  2. Simplified framework: Svelte has a simple and intuitive syntax, making it easier to learn and use compared to other frameworks.
  3. Improved developer experience: Svelte’s approach to building applications can lead to a more streamlined and efficient development experience, as developers don’t have to worry about the overhead of a runtime framework.
  4. Ideal for small to medium-sized applications: Svelte is particularly well-suited for small to medium-sized applications, where its small bundle size and simple syntax can lead to improved performance and developer efficiency.

Svelte is used in a similar way to other front-end frameworks, by creating components and using them to build your user interface. Components in Svelte are made up of a combination of HTML, CSS, and JavaScript, and can be composed to build complex user interfaces.

To use Svelte in a project, you would typically include the Svelte library in your project and start writing components using its syntax. Then, you would use these components to build your application’s user interface, just as you would with other front-end frameworks.

Svelte 3: Getting started

Svelte is a component framework — like React or Vue — but with an important difference. Traditional frameworks allow you to write declarative state-driven code, but there’s a penalty: the browser must do extra work to convert those declarative structures into DOM operations, using techniques like virtual DOM diffing that eat into your frame budget and tax the garbage collector.

Instead, Svelte runs at build time, converting your components into highly efficient imperative code that surgically updates the DOM. As a result, you’re able to write ambitious applications with excellent performance characteristics.

The Svelte docs (quoted above) provide details on the focus Svelte has had as of late that focuses on improving the developer experience.

Let’s take a look at a simple tutorial for how we’d get started using Svelte in just a few minutes.

  1. Install Node.js and npm: To get started with Svelte, you’ll need to have Node.js and npm (Node Package Manager) installed on your computer. You can download them from the official Node.js website.
  2. Create a new project: To create a new Svelte project, you can use the Svelte CLI tool by running the following command in your terminal:
npx degit sveltejs/template my-svelte-app

This will create a new project based on the Svelte template in a directory called “my-svelte-app”.

3. Navigate to the project directory: To navigate to the project directory, run the following command in your terminal:

cd my-svelte-app

4. Start the development server: To start the development server, run the following command in your terminal:

npm run dev

This will start a development server and open a browser window displaying your Svelte application.

5. Write some code: Now that you have a Svelte project set up, you can start writing code. Open the “src/App.svelte” file in your text editor, and you’ll see some example code. You can start by changing the text between the <h1> tags to something of your own.

6. Refresh the browser: After making changes to your code, you can refresh the browser to see the updated version of your application.

This is just a basic tutorial to get you started with Svelte. From here, you can continue to build out your application by creating more components, adding interactivity, and more.

Here is a simple Svelte application that displays a counter that can be incremented or decremented:

<script>
let count = 0;

function increment() {
count += 1;
}

function decrement() {
count -= 1;
}
</script>

<style>
button {
padding: 10px;
font-size: 16px;
margin: 10px;
}
</style>

<h1>Count: {count}</h1>

<button on:click={increment}>+</button>
<button on:click={decrement}>-</button>

In this example, we have a count variable that is initialized to 0. We have two functions, increment and decrement, that are used to modify the value of count. The on:click directive is used to bind the functions to the buttons, so that they are called when the buttons are clicked. Finally, we display the value of count in an <h1> element.

Which one is the best option out of Vue, React or Svelte?

The best option between Vue.js, React, and Svelte depends on your specific needs and the requirements of your project.

Vue.js is a great option for projects that require a lightweight and flexible framework. It is easy to learn and has a gentle learning curve, making it a great choice for developers who are new to front-end development.

React is a popular and widely-used framework, and it is known for its ability to handle complex user interfaces and high performance. React is a good choice for projects that require a powerful and flexible framework, as well as for projects that require integration with other technologies, such as React Native.

Svelte, on the other hand, is a newer framework that is gaining popularity due to its approach to building web applications. Svelte has a small bundle size, making it a great choice for projects that need to be fast and efficient. It also has a simplified syntax, which can make it easier to learn and use for some developers.

It’s not possible to say which one is the “best” option between Vue.js, React, and Svelte, as the choice of which one to use depends on various factors, such as your specific use case, the size and complexity of your project, and your personal preferences and experience.

Vue.js is a popular choice for its simplicity and ease of use, especially for smaller projects and for developers who are new to front-end frameworks.

React is a powerful and flexible library that is widely used for building complex web applications, and it’s particularly well-suited for projects with large amounts of data and for building reusable components.

Svelte is a newer option that is designed to improve performance and developer experience, and it’s well-suited for small to medium-sized projects where its small bundle size and simple syntax can lead to improved performance and developer efficiency.

Performance

All three frameworks, Vue.js, React, and Svelte, have good performance and are capable of handling complex applications. The performance of each framework can vary based on a number of factors, such as the size and complexity of the application, the use of third-party libraries, and the hardware and network conditions.

That being said, Svelte has some advantages in terms of performance compared to other frameworks. Since Svelte compiles its components into vanilla JavaScript code, it eliminates the need for a runtime library, making it a lighter and faster option. Additionally, Svelte’s approach to handling updates to the DOM makes it fast and efficient.

React is also known for its good performance and is capable of handling complex applications with ease. React’s virtual DOM allows it to make efficient updates to the DOM and optimize the render process.

Vue.js also has good performance and is optimized for fast updates to the DOM. It also provides a number of performance optimization techniques, such as lazy-loading components and efficient updates to the virtual DOM.

In conclusion, all three frameworks have good performance, but Svelte and React have some advantages over Vue.js in terms of performance due to their approach to handling updates to the DOM. Ultimately, the performance of your application will depend on a number of factors, including the specific implementation and optimization techniques used.

Functionality

Softjourn says it best when it comes to functionality:

It doesn’t make sense to use a full-stack framework if you only need routing capabilities. Choose a framework that fits the need at hand, rather than choosing something solely for its familiarity. When you understand what your situation requires, this allows you to evaluate different frameworks for their functions.

All three frameworks, Vue.js, React, and Svelte, have robust functionality and can handle complex applications. However, each framework has its own strengths and weaknesses in terms of functionality.

Vue.js is known for its simplicity and ease of use. It provides a straightforward and intuitive API that makes it easy to build applications with a range of functionality. Vue.js also provides a number of out-of-the-box features, such as two-way data binding and a reactive data model, that make it a great choice for building dynamic and interactive applications. Vue also provides the Vue CLI for building and managing projects, and the Vuex library for state management. Vue.js provides a comprehensive set of features for building web applications, including a reactive and composable component system, a template-based syntax, and a centralized store for managing application state.

React is a popular and widely-used framework, and it is known for its ability to handle complex user interfaces and high performance. React provides a powerful set of tools and features for building complex applications, including the React Router for handling routing, and the React Redux library for state management.

Image credit: Ben Holmes 2/2/2022

Svelte, on the other hand, offers a different approach to building web applications, focusing on simplicity and efficient code. Svelte provides a simplified syntax for building components and does not require a runtime library, making it a fast and lightweight option.

Consistency management

All three frameworks, Vue.js, React, and Svelte, provide ways to manage consistency in your applications, but the approach and level of complexity can vary.

Vue.js provides a centralized store called Vuex, which allows you to manage your application’s state in a consistent and predictable way. Vuex provides a set of patterns and techniques for managing state, making it a good choice for projects with complex state management requirements.

React also provides a centralized store, and there are a number of third-party libraries that can be used for state management, such as Redux. React’s approach to state management is flexible and allows you to choose the tools and techniques that work best for your project.

Svelte provides a simpler approach to state management compared to Vue.js and React. Svelte’s approach focuses on making state management a first-class citizen, and it provides a simple and intuitive way to manage state in your application. Svelte also provides built-in support for reactive state, making it easier to build fast and efficient applications.

All three provide ways to manage consistency in your applications, but the approach and level of complexity can vary. Vue.js provides a centralized store with a set of patterns and techniques, while React provides a more flexible approach with a variety of tools and libraries. Svelte provides a simpler and more intuitive approach to state management. The best option will depend on the specific needs and requirements of your project, as well as your personal preferences and experience as a developer.

Best documentation

All three, Vue.js, React, and Svelte, have good documentation that can be used to learn and understand the framework, and to get started building applications. However, the level of detail and the quality of the documentation can vary.

Vue.js has a comprehensive and well-written documentation that covers all aspects of the framework, from getting started to building complex applications. The documentation is also available in multiple languages, making it accessible to a wider audience.

React also has a good documentation that covers all aspects of the framework and provides a clear and concise introduction to React. The documentation also includes a large number of examples and tutorials, making it easier to learn and understand React.

Svelte has a smaller community compared to Vue.js and React, but it still has a good documentation that is well-written and easy to understand. The documentation provides a clear introduction to Svelte and covers all aspects of the framework, making it a good choice for developers who are new to Svelte.

All three have good documentation, but the level of detail and quality can vary. Vue.js and React have more comprehensive and well-written documentation, while Svelte has a smaller community but still has good documentation that is easy to understand. The best option will depend on your specific needs and requirements, as well as your personal preferences and experience as a developer.

Support

The nightmare is known by the unlucky few:

Check to see if the framework you’re interested in using has an active community of support. This is important to do while still in a project’s planning stages. Once you start using a framework, it’s all too common for it to become an integral part of an application. Should maintenance support stop, you might be burdened with taking it on yourself or starting over from scratch to use a new framework!

Both Vue.js and React have strong support and a large community of developers who are actively contributing to their development and growth. The level of support and the size of the community can vary, however, and will depend on your specific needs and requirements.

Vue.js has a large and active community, and it is one of the most popular front-end frameworks in use today. This popularity means that there is a wealth of resources and support available, including a large number of tutorials, forums, and Stack Overflow questions, as well as a vibrant ecosystem of plugins and tools.

React is also a widely-used framework, and it has a large and active community of developers. React is backed by Facebook, which provides a level of stability and security that is hard to match. React also has a large number of resources and support available, including a wealth of tutorials, forums, and Stack Overflow questions, as well as a vibrant ecosystem of plugins and tools.

Svelte generates highly optimized code and has a small footprint, making it well-suited for high-performance applications. React is a highly popular and widely used framework, and it has a large and supportive community. React is well-suited for large and complex applications and has a highly scalable and modular architecture.

Svelte, on the other hand, is a relatively new framework compared to Vue.js and React, but it still has a strong and growing community of developers. Svelte’s popularity is growing rapidly, and it has a number of resources and support available, including a growing number of tutorials, forums, and Stack Overflow questions, as well as a growing ecosystem of plugins and tools.

All three frameworks have strong support and a large community of developers, but the level of support and size of the community can vary. Vue.js and React have larger and more established communities, while Svelte is growing rapidly and has a strong and growing community of developers. The best option will depend on your specific needs and requirements, as well as your personal preferences and experience as a developer.

Production environment

Not all frameworks are equal, and have their own requirements to work. Not every framework needs the latest bells and whistles in order to function, but you should at least make sure the one you’re interested in doesn’t run on deprecated features. Doing so can cause errors and warnings in log files triggered by a framework, which can reflect poorly on your application, developers, and organization in a client’s eyes.

Again, we can’t knock Softjourn for being right.

All three frameworks, Vue.js, React, and Svelte, are suitable for production environments, and each has its own strengths and weaknesses. The best production environment for you will depend on your specific needs and requirements.

Vue.js is known for its simplicity and ease of use, and it has a small footprint, making it well-suited for small to medium-sized projects. Vue.js also has a thriving ecosystem of plugins and tools, making it easier to extend and customize your application.

React is a highly scalable framework that is well-suited for large and complex applications. React has a large and active community of developers, and it is backed by Facebook, which provides a level of stability and security that is hard to match.

Svelte is a relatively new framework compared to Vue.js and React, but it has been designed specifically with performance in mind. Svelte generates highly optimized code, making it well-suited for high-performance applications. Svelte also has a small footprint, making it well-suited for small to medium-sized projects.

All three frameworks are suitable for production environments, and the best option for you will depend on your specific needs and requirements. Vue.js is known for its simplicity and ease of use, React is highly scalable and well-suited for large and complex applications, and Svelte is designed specifically with performance in mind and is well-suited for high-performance applications.

Scalability and loosely coupling

Milan Gatyás hit the nail on the head when he delved into why tightly coupled applications can be hard to add features to or debug, let alone scale:

If you ever happen to see an angry Developer, with eyes wide open, swearing at everything around, there is a good chance he is trying to update a “spaghetti, tightly coupled code.” There are only a few things in the software development world that can get you more upset than when you need to rewrite half of the solution to squeeze in “that simple data source change.” In terms of this blog article, what exactly does the “spaghetti, tightly coupled code” mean? It is the code where components, for example, business logic & code mix with the infrastructure specific code & models, often across the logical layer boundaries. Such structured code is very hard to maintain and the change requests are a nightmare to implement. Loose coupling is a principle which avoids writing a tightly coupled spaghetti code, helping to separate the business logic from the infrastructure logic, and encourages writing the code in isolated components with a clearly described interface. I will share a few stories from my development experience where tight coupling caused (or could cause) me severe problems, and also solutions to prevent this in your development practice. The examples are going to be in the .NET C# language; however, the principles demonstrated apply to the majority of available programming languages.

All three frameworks, Vue.js, React, and Svelte, are capable of being scaled and loosely coupled, and each has its own strengths and weaknesses in this regard. The best option for you will depend on your specific needs and requirements.

Vue.js has a component-based architecture, which makes it easy to scale and reuse code while building loosely coupled applications. Vue.js also has a relatively simple and straightforward API, making it easier to work with and maintain as your application grows.

React has a highly scalable and modular architecture, making it well-suited for large and complex applications. React uses a virtual DOM to improve performance, which provides a high level of abstraction and makes it easier to scale your application as it grows.

Svelte is a relatively new framework compared to Vue.js and React, but it has been designed specifically with performance in mind. Svelte generates highly optimized code, making it well-suited for high-performance applications. Svelte also has a small footprint, making it easier to scale and maintain as your application grows.

All three frameworks, Vue.js, React, and Svelte, have a component-based architecture, which makes it possible to build loosely coupled applications. The level of coupling can vary, however, depending on the specific framework and how it is used.

Vue.js has a relatively simple and straightforward API, making it easy to build loosely coupled components that can be easily reused and combined to build a complete application.

React is known for its modular architecture, which makes it easy to build loosely coupled components that can be combined to build a complete application. React uses a virtual DOM, which provides a high level of abstraction and decouples the components from the underlying DOM structure.

Svelte is a relatively new framework compared to Vue.js and React, but it has been designed specifically with performance in mind. Svelte encourages a highly modular architecture, and it has a small and simple API, making it easy to build loosely coupled components that can be combined to build a complete application.

All three frameworks are capable of building loosely coupled applications, and the level of coupling will depend on the specific framework and how it is used. Vue.js has a relatively simple and straightforward API, React is known for its modular architecture and virtual DOM, and Svelte is designed specifically with performance in mind and encourages a highly modular architecture.

Vue.js, React and Svelte are capable of being scaled, and the ease of scaling will depend on your specific needs and requirements. Vue.js has a relatively simple and straightforward API, React is known for its scalable and modular architecture and virtual DOM, and Svelte is designed specifically with performance in mind and generates highly optimized code.

So which is our winner?

There are several reasons why you might choose to use Svelte over React and Vue.js:

  1. Performance: Svelte generates highly optimized code and has a small footprint, making it well-suited for high-performance applications.
  2. Simplicity: Svelte has a small and simple API, making it easier to learn and use compared to React.
  3. Abstraction: Svelte provides a high level of abstraction, making it easier to build and maintain your application as it grows.
  4. Code size: Svelte generates smaller code compared to React, making it faster to download and run in the browser.
  5. No virtual DOM: Unlike React, Svelte does not use a virtual DOM. This means that Svelte is able to update the DOM more efficiently, which can result in improved performance in certain use cases.
  6. Productivity: Svelte provides a faster development experience and helps you write less code compared to React, making it easier to build and maintain your application.

There are several reasons why you might choose to use React or Vue over Svelte:

  1. Community and ecosystem: React and Vue both have large and supportive communities, with a wealth of resources and libraries available to help you build your application.
  2. Maturity: React and Vue have both been around for several years and have been battle-tested in a variety of use cases. This gives you confidence that these frameworks are robust and stable.
  3. Flexibility: React and Vue have a highly flexible architecture, making it easy to scale and adapt your application as it grows.
  4. Virtual DOM: Both React and Vue use a virtual DOM, which can improve the performance of your application and make it easier to work with dynamic data.
  5. Wide adoption: React and Vue are both widely adopted and used by many companies, meaning that there is a large pool of talent available if you need to hire developers.

That being said, Svelte has its own advantages, such as performance, abstraction, and a smaller code size, which make it well-suited for certain use cases.

Ultimately, the best choice between React, Vue, and Svelte will depend on your specific needs and requirements. If you value community and ecosystem, React or Vue may be a good choice, while if you value performance and abstraction, Svelte may be a better choice.

Community

  • 📦 Svelte: over 100,000 weekly downloads
  • 📦 React: over 6 million weekly downloads

That being said, React is a highly popular and widely used framework, and it has a large and supportive community. React is well-suited for large and complex applications and has a highly scalable and modular architecture.

Ultimately, the best choice between Svelte and React will depend on your specific needs and requirements. If you value performance and simplicity, Svelte may be a good choice, while if you are building a large and complex application, React may be a better choice.

There is no one-size-fits-all answer to which framework is the best. The best option depends on the specific needs and requirements of your project. You should choose the framework that best fits your project’s needs and that you feel most comfortable using.

--

--

Rosie Faulkner

I am a LAMP stack developer working primarily with OOP PHP, JavaScript, ReactJS and MySQL.