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

hydrate-stream

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hydrate-stream

attach javascript handlers to html streams

  • 1.1.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

hydrate-stream

An experimental batteries excluded stream transformer with a simple API for declaritively hydrating elements (like adding onclick handlers).

The motivation behind this is to do server side rendering and selectively hydrating the interactive elements on a page. This is an experiment at building a minimal framework around streaming rendering.

npm install hydrate-stream
import { hydrateStream } from 'hydrate-stream';

const hydrators = [{
    id: 'root',
    key: 'onload',
    value: `
        function loadJS() {
            console.log('script run on load');
        } 
        loadJS();
    `
}, {
    id: 'cta',
    key: 'onclick',
    value: `
        function minimalJS() {
            console.log('script run on click');
        }
        minimalJS();
    `
}];

renderToStaticNodeStream(<Component />).pipe(hydrateStream(hydrators))

Two basic use cases are onclick and onload. For onload a <script> tag is injected after the mapped element.

Usage

See example directory

Credits

  • himalaya

FAQs

Package last updated on 24 Feb 2020

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