Mithril.js builds single-page applications in the browser with routing and XHR utilities included. It ships a small gzipped bundle and targets current major browsers without polyfills.
Overview
Mithril.js is a client-side JavaScript framework for single-page applications. Applications define components with view functions, mount or route them to the DOM, and rely on an autoredraw system that updates only changed parts of the page.
The m function builds virtual DOM trees; m.mount and m.route integrate components with optional URL hashbang routing. Built-in m.request supports XHR calls to backends. Documentation walks through hello world, components, routing, and server interaction in a short tutorial.
The library is distributed via npm and CDN. TypeScript definitions are available from DefinitelyTyped. It is used in production by companies named in the project materials and supports Firefox ESR and recent Firefox, Edge, Safari, and Chrome.
A framework comparison page on the project site contrasts download size and benchmark timings with Vue, React, and Angular for developers evaluating options.
Key features
- Small gzipped runtime
- Virtual DOM rendering
- Built-in hashbang routing
- XHR via m.request
- Component lifecycle methods
- Autoredraw on state changes
- CDN and npm installation
- No required polyfills on listed browsers
Use cases
- Lightweight SPAs without a large toolchain
- Interactive pages with client-side routing
- Apps calling REST APIs from the browser
- Prototypes via CDN and live playgrounds