# simple-ssr

> Universal server-side rendering implementation for Node.js

Latest version **2.2.0** (published 2020-09-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install simple-ssr
pnpm add simple-ssr
yarn add simple-ssr
bun add simple-ssr
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.2.0 |
| Published | 2020-09-15 |
| First published | 2018-08-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 10.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 17 |
| Author | Kirlovon |
| Maintainers | kirlovon |
| Keywords | ssr, pwa, spa, server-size-rendering, puppeteer |

## Links

- npm: https://www.npmjs.com/package/simple-ssr
- Repository: https://github.com/Kirlovon/Simple-SSR
- Issues: https://github.com/Kirlovon/Simple-SSR/issues
- npm.io page: https://npm.io/package/simple-ssr

## Dependencies (1)

- [puppeteer](https://npm.io/package/puppeteer.md) ^5.3.0

## Alternatives

- [@snazzah/davey](https://npm.io/package/@snazzah/davey.md) — 1.5M weekly downloads
- [@vendure/testing](https://npm.io/package/@vendure/testing.md) — 8.3K weekly downloads
- [vue-simple-context-menu](https://npm.io/package/vue-simple-context-menu.md) — 6.6K weekly downloads
- [cypress-webpack-preprocessor-v5](https://npm.io/package/cypress-webpack-preprocessor-v5.md) — 2.1K weekly downloads
- [@backstage/plugin-catalog-backend-module-puppetdb](https://npm.io/package/@backstage/plugin-catalog-backend-module-puppetdb.md) — 1.3K weekly downloads

## Recent versions

- 2.2.0 (latest) — 2020-09-15
- 2.0.5 — 2019-07-13
- 2.0.0 — 2019-07-13
- 1.5.0 — 2019-01-02
- 1.4.7 — 2018-12-18
- 1.4.6 — 2018-12-12
- 1.4.5 — 2018-11-04
- 1.4.0 — 2018-09-26
- 1.3.0 — 2018-09-26
- 1.2.5 — 2018-08-22

## README

<p align="center">
	<img src="https://cdn.rawgit.com/Kirlovon/Simple-SSR/master/logo/Logo.svg" width="256" height="192">
</p>

<p align="center">
	<img src="https://img.shields.io/github/license/Kirlovon/Simple-SSR.svg" alt="License">
	<img src="https://img.shields.io/github/last-commit/Kirlovon/Simple-SSR.svg" alt="Last commit">
	<img src="https://img.shields.io/npm/v/simple-ssr.svg" alt="NPM version">
	<img src="https://img.shields.io/npm/types/simple-ssr.svg" alt="Types">
</p>

## What is it?
Universal server-side rendering implementation for Node.js. Powered by [Puppeteer](https://github.com/GoogleChrome/puppeteer). <br>
This library allows you to preload your web applications on the server side, and send rendered data to the user. <br>

_In simple terms, this module translates this:_
```html
<div id="app"></div>
<script>
	document.getElementById('app').innerHTML = 'Hello, world!';
</script>
```
_To this:_
```html
<div id="app">Hello, world!</div>
<script>
	document.getElementById('app').innerHTML = 'Hello, world!';
</script>
```
*Note: The minimum supported Node version is **Node 7.x***<br>

## Features
* Simplifies crawlers work with your **Single Page Applications** or **Progressive Web Apps**.<br>
* Allows you to cache data, optimizing the server-side rendering process. <br>
* Preload your web applications on the server-side. <br>
* TypeScript support.

## Installation

Installation from the [NPM](https://www.npmjs.com/package/simple-ssr) repository:
```
npm install simple-ssr --save
```

## Example
```javascript
const simpleSSR = require('simple-ssr');

// Puppeteer instance
simpleSSR.browser;

// Enable requests filtering ( Default: true )
simpleSSR.filterRequests = true;

// List of useless for DOM rendering resources
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>...'
	
})();
```

---
_Source: https://npm.io/package/simple-ssr · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
