# Mithril.js: A Compact JavaScript Framework with Built-in Routing and XHR

> Mithril.js is a client-side JavaScript framework for building Single Page Applications. At 8.93 KB gzipped, it includes routing and XHR utilities without external dependencies, making it a self-contained option for teams who want a full SPA toolkit in a small footprint.

**MithrilJS/mithril.js** — A JavaScript Framework for Building Brilliant Applications

- Repository: https://github.com/MithrilJS/mithril.js
- Website: https://mithril.js.org
- Stars: 14,505 · Forks: 922
- Language: JavaScript
- License: MIT
- Published: 2026-09-21 · Updated: 2026-09-21 · Language: en
- Canonical page: https://hysenlabs.com/projects/mithriljs-mithril-js

## What Mithril.js Solves and Who It Is For

Mithril.js targets developers building Single Page Applications who want a full toolkit without the overhead of combining separate libraries. React requires a separate router (React Router) and HTTP client. Vue requires similar additions. Mithril.js includes routing and an XHR utility in its 8.93 KB gzipped bundle.

The project is described on its README as used by companies including Vimeo and Nike, and by the open-source chess platform Lichess. This points to its practical viability in production beyond hobby projects.

The framework supports the latest two versions of Firefox, Edge, Safari, and Chrome, plus Firefox ESR, without polyfills. The README explicitly notes that no polyfills are required, which distinguishes it from frameworks that target older browser support through added weight.

The target audience is developers who want a self-contained SPA framework with a hyperscript API, teams building internal tools or specialized interfaces where bundle size matters, and developers maintaining existing Mithril.js applications.

## How Mithril.js Works: Virtual DOM and Hyperscript

Mithril.js uses a virtual DOM diffing approach similar to React, but the primary way to describe UI is through hyperscript (`m()` calls) rather than JSX, though JSX can be configured. Components are plain JavaScript objects or closures with a `view` function that returns a virtual DOM tree.

The repository structure reflects this: `render.js` is the virtual DOM renderer, `mount.js` handles mounting components to the DOM, `route.js` is the router, `request.js` is the XHR utility, and `stream.js` is the reactive stream module. Each module is also available as a standalone file in the top-level directory (`render.js`, `route.js`, `request.js`, `stream.js`) so they can be imported individually.

The bundled `mithril.js` (development) and `mithril.min.js` (production) files in the repository combine these modules into a single distributable. The build system uses a custom bundler script (`scripts/bundler.js`) driven by esbuild and minimization via terser, invoked through npm scripts in `package.json`.

## Installing Mithril.js

Via npm:

```bash
npm install mithril --save
```

Via CDN, using either unpkg or jsDelivr:

```html
<script src="https://unpkg.com/mithril/mithril.js"></script>
```

The CDN path requires no build step, making it practical for small projects or prototypes where a bundler would be overhead. The production minified file is available at `https://unpkg.com/mithril/mithril.min.js` or the jsDelivr equivalent.

TypeScript type definitions are available from DefinitelyTyped and can be installed separately:

```bash
npm install @types/mithril --save-dev
```

The README points to the Getting Started guide at mithril.js.org for first-project instructions. The API reference and example applications are also on that documentation site.

## Routing, XHR, and Streams

The built-in router (`m.route`) handles client-side navigation without an external library. Routes are defined as a map of path patterns to components, and Mithril.js intercepts link clicks and browser history events to render the appropriate component.

The XHR utility (`m.request`) wraps the browser's fetch API or XMLHttpRequest with a simpler interface that integrates with Mithril.js's redraw cycle. After a request completes, the component tree re-renders automatically without manual state management calls.

The stream module (`mithril/stream`, available separately) provides a reactive primitive for managing state changes. It is an optional addition; many Mithril.js applications manage state through plain JavaScript objects in component closures without the stream module.

This bundled approach means a basic Mithril.js application needs only `npm install mithril` and no additional routing or HTTP libraries.

## Mithril.js vs. Alpine.js

Alpine.js is a lightweight JavaScript framework that adds reactive behavior to server-rendered HTML through attributes, without a virtual DOM or a full SPA architecture. It is designed to sprinkle interactivity onto existing pages rather than manage the full rendering lifecycle of a single-page application.

Mithril.js is a client-side SPA framework that owns the rendering of its component tree, including routing between views. The two tools solve different problems. Alpine.js is appropriate when the server renders HTML and JavaScript should handle isolated interactive components. Mithril.js is appropriate when JavaScript renders the full application UI and manages navigation between views.

The choice between them is not about performance or bundle size alone. It is about architecture: does the server own the HTML structure, or does JavaScript?

## Limitations and Where Mithril.js Is the Wrong Choice

Mithril.js's ecosystem is small compared to React or Vue. Third-party component libraries, design system integrations, and community plugins built specifically for Mithril.js are limited. Teams who want a rich library of pre-built UI components will need to either build their own or integrate generic CSS frameworks without framework-specific bindings.

The hyperscript API is unfamiliar to developers who have only used JSX. While JSX can be configured with a build tool, the default writing style of `m('div', {class: 'container'}, 'Hello')` requires a mental shift that takes time for teams coming from React.

The last release was v2.3.8 on 2025-11-08. Development continues at a slow pace. New features are not being added at the rate of larger frameworks. Teams who need active community support through forums and paid support options will find less of that around Mithril.js than around React or Vue.

## Maintenance, Version History, and License

Mithril.js is currently at v2.3.8. The v2.3.8 release was published on 2025-11-08. The last push to the repository was on 2026-08-13. The project is authored by Leo Horie and maintained under the MIT license.

The MIT license permits commercial use, modification, redistribution, and sublicensing without restriction. There are no copyleft conditions. The `@types/mithril` DefinitelyTyped package follows its own versioning independent of the main package.

The repository uses a custom test runner (`ospec`) rather than Jest or Vitest, which is notable for contributors. Tests live in `tests/`. The build system produces three outputs: `mithril.js` (development), `mithril.min.js` (production), and a minified stream module, all generated from `browser.js` as the entry point.

## Conclusion

Mithril.js is a strong choice for projects where bundle size and dependency count matter more than ecosystem breadth. Its self-contained design means no separate router, no separate HTTP client, and no build tool required for a basic setup. Teams already invested in React's ecosystem or who need the deep tooling around Vue will not find Mithril.js a replacement. The last release was v2.3.8 on 2025-11-08, and the last push was on 2026-08-13. The project is not inactive, but release cadence is slow. Verify that any third-party Mithril.js plugins you plan to use are compatible with v2.3.8 before committing to the framework for a new project.

## FAQ

### What is Mithril.js?

Mithril.js is a client-side JavaScript framework for Single Page Applications. At 8.93 KB gzipped, it includes built-in routing and XHR utilities. The README notes it is used in production by Vimeo, Nike, and the Lichess chess platform.

### Is Mithril.js dead?

Mithril.js is not dead, but development is slow. The last release was v2.3.8 on 2025-11-08, and the last repository push was on 2026-08-13. The project receives maintenance updates but is not adding major new features at a rapid pace.

### How does Mithril.js compare to Alpine.js?

Mithril.js is a full SPA framework that renders component trees from JavaScript and manages client-side routing. Alpine.js adds reactive attributes to server-rendered HTML without a virtual DOM or SPA architecture. They target different patterns: Mithril.js owns the full rendering lifecycle, Alpine.js enhances existing server-rendered pages.

## Sources

- [License: MIT](https://github.com/MithrilJS/mithril.js/blob/main/LICENSE)
- [MithrilJS/mithril.js on GitHub](https://github.com/MithrilJS/mithril.js)
- [Project website](https://mithril.js.org)
- [README](https://github.com/MithrilJS/mithril.js/blob/main/README.md)
- [Releases](https://github.com/MithrilJS/mithril.js/releases)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/mithriljs-mithril-js
