Mithril vs Preact
Which should you use? A side-by-side look at what each one does, who it suits, what it costs, how hard it is to set up, and where each falls short.
Open source · MIT
A small JavaScript framework for building single page web apps, with routing and XHR built in.
Open source · MIT
A small (about 4kB) React-style library for building user interfaces in JavaScript.
The short answer
Choose Mithril if you need…
- Developers who want a small framework with routing and HTTP utilities included
- Teams building single page apps who prefer a lightweight alternative to larger frameworks
- Projects targeting modern browsers, since the README says no polyfills are required
Choose Preact if you need…
- Web developers who already know React and want a lighter library
- Projects where small bundle size matters, such as pages loaded over slow connections
- Teams that want an optional compatibility alias (preact/compat) to reuse React-based code
- Developers building apps that need server-side rendering with hydration
Side-by-side
| Mithril | Preact | |
|---|---|---|
| Type | Library | Library |
| Price | Free and open source | Free and open source |
| Licence | MIT | MIT |
| GitHub stars | 14.5k | 39k |
| Setup difficulty | Intermediate | Intermediate |
| How you get it | Install with a package manager | Install with a package manager |
| Main language | JavaScript | JavaScript |
| Last code update | 3 months ago | 4 days ago |
What each one is
Mithril
Mithril.js is a client-side JavaScript framework for building single page applications, where the page updates in the browser without full reloads. According to its README, it is small (about 8.93 KB gzipped) and includes routing and XHR (network request) utilities without extra packages. It is installed via npm or loaded from a CDN.
Preact
Preact is a JavaScript library for building user interfaces out of reusable components, using an API that closely follows React. The README describes it as a fast, roughly 4kB alternative to React with a similar modern API, covering components, hooks, JSX, and a virtual DOM. Developers use it when they want React-style code with a much smaller download size.
Best for
Mithril
- Developers who want a small framework with routing and HTTP utilities included
- Teams building single page apps who prefer a lightweight alternative to larger frameworks
- Projects targeting modern browsers, since the README says no polyfills are required
Preact
- Web developers who already know React and want a lighter library
- Projects where small bundle size matters, such as pages loaded over slow connections
- Teams that want an optional compatibility alias (preact/compat) to reuse React-based code
- Developers building apps that need server-side rendering with hydration
Strengths
Mithril
- Small size, about 8.93 KB gzipped according to the README
- Routing and XHR utilities are included out of the box
- MIT licensed with an active community on Zulip and Stack Overflow
Preact
- Very small size (the README states about 4kB), which helps page load time
- Familiar React API, including class components, hooks, and functional components
- MIT licensed with a large community and many stars on GitHub
Not ideal for
Mithril
- People who need server-side rendering or a backend framework, since the README only describes client-side use
- Non-programmers looking for a no-code tool, since it requires writing JavaScript
- Projects needing support for old browsers beyond Firefox ESR and the last two versions of major browsers, per the README
Preact
- Complete beginners who have never written JavaScript; the README assumes familiarity with components and modern JS syntax
- Projects that depend on React-only libraries without testing compatibility, since the README only describes compatibility as 'extensive' via an alias and does not list limits
- Native mobile app development, which the README does not mention
Trade-offs
Mithril
- The README does not detail the feature set beyond routing and XHR, so the scope is unclear from this source alone
- Documentation is hosted on an external site, and the README is brief
- Browser support is limited to recent versions as listed in the README
Preact
- The README is truncated and gives limited detail on edge-case React compatibility
- Some React ecosystem libraries may need the compat layer or may not work fully
- Tooling such as DevTools and HMR depends on additional setup that the README only briefly mentions
Getting started
Mithril
Install via npm
npm install mithril --saveInstall TypeScript type definitions (optional)
npm install @types/mithril --save-devFrequently asked questions
What is the difference between Mithril and Preact?
Mithril: A small JavaScript framework for building single page web apps, with routing and XHR built in. Preact: A small (about 4kB) React-style library for building user interfaces in JavaScript. Mithril suits developers who want a small framework with routing and http utilities included, while Preact suits web developers who already know react and want a lighter library.
Are Mithril and Preact free?
Mithril: Free and open source. Preact: Free and open source.
Is Mithril or Preact more popular?
Preact has more GitHub stars (39k) than Mithril (14.5k). Popularity isn't the same as fit — check which one matches your use case above.
What are other alternatives to Mithril and Preact?
Other options people compare them with include React, Svelte, Hyperapp, Gin, Million.js.
Keep comparing
Built from our catalogue entries for both products: open-source details come from each project's README (AI-assisted, refreshed weekly) and GitHub data; AI-tool details are editorial. Spotted something wrong? Let us know from either product's page.