svelte
Svelte is a radical new approach to building user interfaces that shifts the work of the framework from the browser to a compile step at build time. Unlike Reac…
Installation
npm install svelte
yarn add svelte
pnpm add svelte
Import
// Inside .svelte files
Quick Example
<script>
let count = $state(0);
</script>
<button onclick={() => count++}>
Clicked {count} times
</button>About svelte
Svelte is a radical new approach to building user interfaces that shifts the work of the framework from the browser to a compile step at build time. Unlike React or Vue which use a virtual DOM to detect changes and update the UI, Svelte compiles components into highly efficient imperative code that surgically updates the DOM when state changes. This results in smaller bundle sizes and better runtime performance since there is no framework overhead in the browser. Svelte components are written in .svelte files that combine HTML, CSS, and JavaScript in a single file with an intuitive syntax. Reactive declarations use the $: label, and state is managed with simple variable assignments rather than hooks or observables. Svelte 5 introduced runes, a new reactivity system using $state, $derived, and $effect for more explicit and flexible state management. SvelteKit, the official application framework, provides routing, server-side rendering, and deployment adapters. Svelte is praised for its small learning curve, excellent documentation, and developer satisfaction.
Quick Facts
| Package | svelte |
| Category | Framework |
| Weekly Downloads | 2M+ |
| License | MIT |
| Install | npm install svelte |
Related Packages
React is the most popular JavaScript library for building user interfaces, developed and maintained …
Vue.js is a progressive JavaScript framework for building user interfaces, created by Evan You in 20…
Preact is a fast 3kB alternative to React with the same modern API. It provides the thinnest possibl…
Solid is a declarative JavaScript library for creating user interfaces that compiles templates to re…
Astro is a modern web framework designed for building content-driven websites like blogs, documentat…
Browse npm Packages by Category
Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.