@hangarlabs/web-prerender
Works as a middleware to prerender JS generated websites built on React.js or Angular.js.
Last updated 6 months ago by ejbogantes .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @hangarlabs/web-prerender 
SYNC missed versions from official npm registry.

web-prerender

This package caches a pre-rendered version of an URL using Puppeteer and Redis.

Nowadays we have websites that are JS generated and the search engine crawling bots cannot fetch the metadata causing bad SEO results, so with this package you can serve a pre-rendered version of the websites with all required metadata.

Requirements

  1. Node v10.16.3 LTS or higher https://nodejs.org/en/.
  2. TypeScript https://www.typescriptlang.org/.
  3. TS Lint https://palantir.github.io/tslint/.
  4. Redis Client https://www.npmjs.com/package/redis.

How to install the package

Check the required Node.js version with

nvm use

Install with NPM or Yarn

npm install or yarn install

Usage TypeScript

Usage with NPM or Yarn

npm install @hangarlabs/web-prerender --save
or
yarn add @hangarlabs/web-prerender

import { IOptionsPreRenderQueue, Ssr } from  "web";

  const prerender  =  new  Ssr({
    redisDatabase:  parseInt(env.redis.db, 10),
    redisHost :  env.redis.host,
    redisPort :  env.redis.port  as  number,
    } as  IOptionsPreRenderQueue);

Create a RedisClient ...
[https://www.npmjs.com/package/redis](https://www.npmjs.com/package/redis)

prerender
.setRedisCache(RedisClient)
.initHandlerBull()
.preRender()
const url = "https://www.google.com";
const {html, ttRenderMs} =  await  prerender.ssr(url);

Using Express.js you can something like this:
if (html) {

response.set("Server-Timing", `Prerender;dur=${ttRenderMs};desc="Headless 				render time (ms)"`);
return  response.status(200)
.send(html);

}

Develop

Develop with NPM or Yarn

npm run dev yarn dev

Build

Build with NPM or Yarn

npm run build or yarn build

Test

Build with NPM or Yarn

npm run test or yarn test

Contact

Hangar Corporate Team corporate@thehangar.cr Report any issue here: https://github.com/hangarlabs/web-prerender/issues

Current Tags

  • 0.0.5                                ...           latest (6 months ago)

5 Versions

  • 0.0.5                                ...           6 months ago
  • 0.0.4                                ...           6 months ago
  • 0.0.3                                ...           6 months ago
  • 0.0.2                                ...           7 months ago
  • 0.0.1                                ...           8 months ago
Downloads
Today 0
This Week 5
This Month 5
Last Day 0
Last Week 0
Last Month 0
Dependencies (5)
Dev Dependencies (12)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |