About
This package extends Mithril with Signals for fine-grained reactivity—components re-render only when their dependencies change—plus Store for persistent state (localStorage, sessionStorage), SSR with hydration, and htm for JSX-like syntax without a build step. Stream and the built-in request API are removed (use fetch() instead). TypeScript and Bun by default.
bun add @bitstillery/mithril
Types are built-in; no @types package needed.
bun init my-app— choose Blank. Thencd my-appandbun add @bitstillery/mithrilAdd to
package.jsonscripts:"dev": "bun index.html"Add to
tsconfig.jsonundercompilerOptions:"jsx": "react","jsxFactory": "m","jsxFragmentFactory": "m.Fragment"Create
src/index.tsx:
import m, {state, MithrilComponent} from '@bitstillery/mithril'
const $s = state({count: 0})
class App extends MithrilComponent {
view() {
return (
<div>
<p>Count: {$s.count}</p>
<button onclick={() => $s.count++}>Increment</button>
</div>
)
}
}
m.mount(document.getElementById('app'), App)
- Create
index.htmlat project root:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>My App</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="src/index.tsx"></script>
</body>
</html>
bun run dev→ http://localhost:3000