simple-ssr
Universal server-side rendering implementation for Node.js
Last updated 2 months ago by kirlovon .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install simple-ssr 
SYNC missed versions from official npm registry.

License Last commit NPM version Types

What is it?

Universal server-side rendering implementation for Node.js. Powered by Puppeteer.
This library allows you to preload your web applications on the server side, and send rendered data to the user.

In simple terms, this module translates this:

<div id="app"></div>
<script>
	var element = document.getElementById('app');
	element.innerHTML = 'Hello, world!';
</script>

To this:

<div id="app">Hello, world!</div>
<script>
	var element = document.getElementById('app');
	element.innerHTML = 'Hello, world!';
</script>

Note: The minimum supported Node version is Node 7.x

Features

  • Simplifies crawlers work with your Single Page Applications or Progressive Web Apps.
  • Preload your web applications on the server-side.
  • Allows you to cache data, optimizing the server-side rendering process.
  • In some cases improves performance and loading speed of your web app.
  • TypeScript support.

Installation

Installation from the NPM repository:

npm install simple-ssr --save

Example

const simpleSSR = require('simple-ssr');

// Puppeteer instance
simpleSSR.browser;

// Enable requests filtering ( Default: true )
simpleSSR.filterRequests = true;

// List of useless for rendering content
simpleSSR.blockedRequest = ['stylesheet', 'image'];

(async() => {

	// Put there Puppeteer config
	await simpleSSR.start({ headless: true });

	let result = await simpleSSR.render('http://example.com/', {
		
		 // Rendering timeout
		timeout: 1000,

		// When to consider navigation succeeded.
		waitUntil: 'load',

		 // DOM target to wait for
		domTarget: ['body', 'h1']
	});

	console.log(result.url) // 'http://example.com/'
	console.log(result.time) // 10000
	console.log(result.html) // '<!DOCTYPE html>...'
	
})();

Current Tags

  • 2.0.5                                ...           latest (2 months ago)

9 Versions

  • 2.0.5                                ...           2 months ago
  • 2.0.0                                ...           2 months ago
  • 1.5.0                                ...           9 months ago
  • 1.4.7                                ...           9 months ago
  • 1.4.6                                ...           9 months ago
  • 1.4.5                                ...           10 months ago
  • 1.4.0                                ...           a year ago
  • 1.3.0                                ...           a year ago
  • 1.2.5                                ...           a year ago
Maintainers (1)
Downloads
Today 1
This Week 1
This Month 2
Last Day 0
Last Week 0
Last Month 9
Dependencies (1)
Dev Dependencies (4)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |