New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

lev-react-renderer

Package Overview
Dependencies
Maintainers
3
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lev-react-renderer

A React rendering middleware for Restify

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-85.71%
Maintainers
3
Weekly downloads
 
Created
Source

React rendering middleware for Restify

A Restify middleware that provides a res.render method for sending HTML responses based on a React component. styled-components is supported.

The rendering is done server-side (SSR) but isomorphic / client-side rendering is also supported by providing a link to your bundle.

Installation

npm install --save lev-react-renderer

Usage

'use strict';

const restify = require('restify');
const reactRenderer = require('lev-react-renderer');

const formatText = restify.formatters['text/plain; q=0.3'];

const httpd = restify.createServer({
  formatters: {
    'text/html': formatText
  }
});

httpd.use(reactRenderer());

httpd.get('/', (req, res, next) => {
  res.render(YourApp, yourProps);
});

httpd.listen(8080, '0.0.0.0', () => {
  log.info('%s listening at %s', httpd.name, httpd.url);
});

Isomorphic rendering

In addition to Server-Side Rendering (SSR) this library supports 'hydrating' your application on the client-side. To do so, simply provide the location of your 'bundle' when creating the middleware. e.g.

httpd.use(reactRenderer({
  bundle: 'public/bundle.js'
}));

The bundle should call the hydrate function with the same component you are passing to res.render(). e.g.

import { hydrate } from 'lev-react-renderer';
import { YourApp } from './YourApp';

hydrate(YourApp);

Working on this repository

To test changes to this repository simply run:

make test

FAQs

Package last updated on 11 Feb 2022

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