Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@bitovi/incremental
Advanced tools
Accelerated server-side rendering.
Install from npm:
npm install @bitovi/incremental
Or Yarn:
yarn add @bitovi/incremental
The Getting Started guide goes over everything in much more depth but here is a primer.
Once you've installed incremental you can use the CLI to start a server and point at an HTTP(S) endpoint like so:
node_modules/.bin/incremental https://bitovi.github.io/dog-things-react/
This will tell you to visit http://localhost:8080 where you see the sight load incrementally. Continue on with the guide which walks you through what is happening and how to integrate this into your workflow.
incremental comes with CLI and JavaScript APIs.
The command-line interface is the easiest way to use incremental. Provide a path to your production HTML file and a few options, if needed. The HTML file can be a local path or a remote HTTP(S) address:
Locally
node_modules/.bin/incremental build/index.html
Remote
node_modules/.bin/incremental https://bitovi.github.io/dog-things-react/
The following CLI flags are available for use:
When running from a remote HTTP(S) address, incremental will download static assets and serve them from a local cache. That cache will be used until the next time the server starts, at which time they'll be re-downloaded.
This means that a deployed incremental server doesn't need to be redeployed when you release a new version of your front-end app; but you will need to restart the server.
See this issue for discussion on more advanced caching coming in the future.
incremental takes a function that is given a rendering context. This includes a document, the request and response objects. A function is returned with a signature of (request, response)
and can be used as Express middleware, directly with require('http')
, etc.
Here's an example that uses http module directly:
const incremental = require('@bitovi/incremental');
const { ReactDOM, App } = require('./dist/webpack-build-whatever.js');
const handler = incremental(({ document, request }) => {
let root = document.createElement('div');
root.setAttribute("id", "root");
document.body.appendChild(root);
ReactDOM.render(React.createComponent(App), root);
});
require('http').createServer(handler).listen(8080);
Note the above doesn't handle serving static assets. If you are using the http module directly you probably already know how to handle this, but most will likely want to use a framework like Express. Here's an example that does so:
const incremental = require('@bitovi/incremental');
const { ReactDOM, App } = require('./dist/webpack-build-whatever.js');
const express = require('express');
const app = express();
// Add any normal Express middlware you use here.
app.use(express.static(__dirname + '/build', { index: false }));
// Add this last.
app.use(incremental(({ document, request }) => {
let root = document.createElement('div');
root.setAttribute("id", "root");
document.body.appendChild(root);
ReactDOM.render(React.createElement(App), root);
}));
app.listen(8080);
Note that
{ index: false }
is provided toexpress.static
. This disables serving the index.html file for routes like/
. This is disabled in this example because incremental will handle those routes.
incremental takes a handler function as its only argument. That function receives a context object that contains the following properties:
.write()
or .end()
as incremental calls those itself.incremental utilizes recent additions to the browser specs such as preload, fetch, and ReadableStream.
As of today incremental rendering is possible in Chrome and Safari >=12.
In browsers that don't support these technology incremental will fallback to the traditional SSR method of waiting for a fully rendered page. We call these separate strategies:
See the latest releases on GitHub.
FAQs
Incremental rendering - Boot your SPA faster
We found that @bitovi/incremental demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
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.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.