
Snabbdom
A small, fast virtual DOM library for building and updating web interfaces efficiently.
- Stars
- 12.4k
- Forks
- 1.1k
- Licence
- MIT
- Language
- TypeScript
- Last update
- 5 months ago
- Type
- Library
What it is
Snabbdom is a JavaScript library that manages a virtual DOM, a lightweight in-memory description of what a web page should look like. When your app state changes, it compares the new description with the old one and updates only the parts of the real page that changed. Its core is intentionally small, and extra features such as classes, styles, properties and event listeners are added through optional modules.
- Render a view from application state and patch only the changed DOM nodes on each update
- Toggle CSS classes, set inline styles and attach click handlers using the included modules
- Create SVG graphics with the h helper
- Build animated UI transitions, such as reordering elements, using the style module's delayed properties
Great for
- Developers building interactive web interfaces who want a small, low-level rendering library
- Teams that prefer to pick only the modules they need rather than adopt a full framework
- Projects that need to integrate rendering with functional or reactive (FRP) code
- Developers who want to read and understand the rendering core end to end
Not ideal for
- Beginners looking for a complete framework with routing, state management and tooling included, since the README describes Snabbdom as a focused library
- Projects that need a large built-in ecosystem of components, as the README lists mainly a few third-party packages
How to get it
- 1
Install with a package manager
You'll need: Node.js (version not specified in the README excerpt)
Clone the repository
git clone https://github.com/snabbdom/snabbdom - 2
Run it
- Install the snabbdom package from npm in your project
- Import init and the modules you need, then create a patch function with init([...modules])
- Create a view with h("div", ...) and call patch(container, vnode) to render it
- Create an updated vnode and call patch(vnode, newVnode) to update the page
- 3
Get the most out of it
- Use the class, props, style and eventlisteners modules to cover common UI needs without extra code
- Use thunks to optimize the diff and patch process further, as described in the README
- Use the JSX support, including TypeScript types, if you prefer JSX syntax
- Consider third-party packages such as snabbdom-to-html for server-side HTML output
Downloads
Strengths
- The core is about 200 SLOC, so it is easy to read and understand
- Modular design lets you include only the features you use
- The README describes it as among the fastest virtual DOM libraries, with a built-in JSX option
Trade-offs
- Fewer built-in features than full frameworks; routing and state management are not mentioned in the README
- Requires following its specific patch and vnode conventions, which are described as necessary for its design
- Documentation is limited to the README excerpt provided here, so some advanced areas are unclear
How it compares
| Project | Stars | Type | Level | Updated | Best for |
|---|---|---|---|---|---|
| snabbdom (this) | 12.4k | Library | intermediate | 5 months ago | Developers building interactive web interfaces who want a small, low-level rendering library |
| inferno | 16.5k | Library | intermediate | 6 days ago | Developers already familiar with React who want a React-like API |
| preact | 39k | Library | intermediate | 4 days ago | Web developers who already know React and want a lighter library |
Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.