choo-ssr
Choo plugin for SSR with Fastify
Last updated a year ago by goto-bus-stop .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install choo-ssr 
SYNC missed versions from official npm registry.

choo-ssr

Server-side rendering for Choo with Fastify

Usage - Install - License: MIT

stability standard

Usage

See examples for more

// app.js

const choo = require('choo')
const html = require('choo/html')
const ssr = require('choo-ssr')

function main () {
  const app = choo()

  const page = view => (
    ssr.html(
      ssr.head(ssr.state()),
      ssr.body(view)
    )
  )

  app.use(ssr())
  app.route('/', page(home))
  app.route('*', page(notfound))
  app.mount('html')

  function home (state, emit) {
    return html`<div>Hello World!</div>`
  }

  function notfound (state, emit) {
    return html`<div>Not found :(</div>`
  }

  return app
}


if (typeof window !== 'undefined') {
  main()
}

module.exports = main
// server.js
const fastify = require('fastify')()

fastify.register(require('choo-ssr/fastify'), {
  app: require('./app'),
})

Install

npm install choo-ssr

License

MIT

Current Tags

  • 0.2.2                                ...           latest (a year ago)

5 Versions

  • 0.2.2                                ...           a year ago
  • 0.2.1                                ...           3 years ago
  • 0.2.0                                ...           3 years ago
  • 0.1.1                                ...           3 years ago
  • 0.1.0                                ...           3 years ago
Downloads
Today 0
This Week 0
This Month 3
Last Day 0
Last Week 1
Last Month 0
Dependencies (3)
Dev Dependencies (1)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |