All Projects → roxiness → tossr

roxiness / tossr

Licence: other
Universal SSR renderer powered by JSDOM

Programming Languages

javascript
184084 projects - #8 most used programming language
tossr

Universal SPA to SSR

Render HTML from any SPA.

Install

npm i tossr

Usage example

const { tossr } = require('tossr')

const template = 'dist/index.html'
const script = 'dist/app.js'
const url = '/blog/ssr-is-fun'

const html = await tossr(template, script, url)

Related libraries

  • Spassr Small Express server with built in SSR
  • Spank Generate a static site from any SPA

API

Table of Contents

tossr

Renders an HTML page from a HTML template, an app bundle and a path

Parameters
  • template string Html template (or path to a HTML template).
  • script string Bundled JS app (or path to bundled bundle JS app).
  • url string Path to render. Ie. /blog/breathing-oxygen-linked-to-staying-alive
  • options Partial<Config>? Options

Returns Promise<string>

Config

Type: object

Properties
  • host string hostname to use while rendering. Defaults to http://jsdom.ssr
  • eventName string event to wait for before rendering app. Defaults to 'app-loaded'
  • beforeEval Eval Executed before script is evaluated.
  • afterEval Eval Executed after script is evaluated.
  • silent boolean Don't print timestamps
  • inlineDynamicImports boolean required for apps with dynamic imports
  • timeout number required for apps with dynamic imports
  • dev boolean disables caching of inlinedDynamicImports bundle
  • errorHandler function

Eval

Called before/after the app script is evaluated

Type: Function

Parameters

Party vector created by gstudioimagen - www.freepik.com

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].