Skip to content

How to: Front (choo app)

William edited this page Oct 4, 2016 · 1 revision

How to

If you already installed the npm package just skip this part, otherwise just install it: npm install metalsmith-choo

Once you installed it, you need to make a few changes on your choo app :

const wrapper = require('metalsmith-choo/chooWrap')
const choo = require('choo')
const html = require('choo/html')

const app = choo()
app.model(/* your models */})

[...]

/* Replace 
const tree = app.start()
document.body.appendChild(tree)
*/

module.exports = wrapper(app)

The wrapper will take care of the mounting for you. It will detect if you calling it from your metalsmith (static build) or your browser. If you are in the browser, the wrapper will rehydrate your choo app.

Clone this wiki locally