Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

choo-ssr-lbry

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

choo-ssr-lbry

Choo plugin for SSR with Fastify

  • 0.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

FAQs

Package last updated on 27 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc