Photo by RetroSupply on Unsplash
React vs Svelte? Why you may want to use a framework rather than library.
What to consider in your choice for a framework.
React like we all know is basically just a library, and if you aren't sure why that's not the case for other JavaScript frameworks like Vuejs, NextJs, Angular(Typescript) or Gatsby.
Here's why, React is a boilerplate for creating whatever you want and however you want it. It basically gives you a level plain field to create a lightweight web application using JavaScript. You may have heard that with Svelte you write less code, and that's true. While React uses useEffect for reactivity, Svelte handle reactivity using "$:", and it could take variables and expressions. isn't that awesome🙂.
React, like other frameworks is a single page application (SPA), that allows for easy and fast page load and routing using node servers without the native page load where each page is a standalone html file that gets download and cached by the browser on every visit.
Say for instance you would like to add routing to React, you may have to install a package for that called react-router-dom. With Sveltekit, you need not to install any package to integrate routing into your application.
Svelte unlike React is regarded as a framework because it has some great feature within it as follows:
- Routing
- Modules
- Layouts
- Events:Adapter
- Command-line Interface
- Service Workers
- SEO Support
- Element Directives
- Animation
and more...
Svelte compared to other framework is quite easy to learn compared to React, you wouldn't have to learn how to use other third party libraries to build a full-fledge framework, Svelte already gives you most of what you need right out of the box.