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

@vrbo/catalyst-render

Package Overview
Dependencies
Maintainers
9
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vrbo/catalyst-render

A Hapi.js plugin to aid in server-side rendering using Handlebars and React.

  • 2.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
9
Weekly downloads
 
Created
Source

@vrbo/catalyst-render

NPM Version Build Status Dependency Status NPM Downloads

Introduction

A Hapi.js plugin that works with the catalyst-server to aid in server-side rendering using Handlebars and React. It allows you to relate a Handlebars template and a React component to a route. This route will automatically be registered with the server and will decorate request.pre.component with the react component and the request.pre.template with the template. It will also register @hapi/vision and server views with Handlebars rendering for the page scaffolding.

Usage

Install:

npm install @vrbo/catalyst-render

Register the plugin in the application's manifest:

...
"register": {
    "catalyst-render": {
        "plugin": "require:@vrbo/catalyst-render",
        "options": {
            "routes": [{
                "route": "require:./routes/application.js",
                "component": "require:../components/App/server.js",
                "template": "./templates/welcome.hbs"
            }]
        }
    }
}
...

The require:./routes/application.js points to a route file that exports a Hapi.js route object and will look something like this (with a very basic render):

module.exports = {
    method: 'GET',
    path: '/',
    options: {
        handler(request, h){
            const template = request.pre.template;
            const Component = request.pre.component;
            const body = ReactDOMServer.renderToString(<Component/>);
            return h.view(template, { body })
        },
        id: 'root'
    }
}

API

Register the plugin server.register(server, options)

ParamTypeDescription
serverobjectHapi.js server
optionsobjectOverriding options
options.routesarrayA list of route objects to register on server.
[options.viewsOptions]objectOptions to add to (or override) when on server.views method is called for adding things like partials ,, layouts, helpers and others.
[options.visionOptions]objectProxy for options when registering @hapi/vision.
[options.resolveAssetHelper]objectA Handlebars helper to help resolve static assets, as in publishing to a CDN.
options.resolveAssetHelper.namestringName of helper.
options.resolveAssetHelper.helperfunctionHelper function.

Route

This is an object for registering routes, React components, and templates

PropertyTypeDescription
routeobjectHapi.js route object to register on server.
componentobjectA React component to render. Available as request.pre.component in handler in above route.
templatearrayA Handlebars template to use to render page scaffold. Available as request.pre.template in handler in above route.

Further Reading

Keywords

FAQs

Package last updated on 19 Nov 2019

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