Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including mithril-n with all npm packages installed. Try it out:

var mithrilN = require("mithril-n")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

mithril-n v1.0.1

Pure DOM nodes in Mithril templates.

Travis – build statusCode climateDavid – status of dependenciesCode style: airbnb


Pure DOM nodes in Mithril templates.


Using bower:

$ bower install mithril-n

Using npm:

$ npm install mithril-n


It's really just Mithril's m(), which accepts DOM nodes as children as well as original arguments.

So this JavaScript*:

import m from "mithril";
import n from "mithril-n";

    n("mama", m(".son")),
    "A happy family"

…will result in:

    <div class="son"></div>
  A happy family

* I'm using ES6 syntax here – brought to us today by great projects like babel. When you download a release of mithril-n, you get two versions bundled: one for ES6, one for ES5 (available as CommonJS, RequireJS and as a global variable).

If you're interested in implementation details, have a look at the annotated source.


Many thanks to this fine gentleman for his invaluable input:


MIT © Tomek Wiszniewski


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free