tossr
tossr copied to clipboard
Universal SSR renderer powered by JSDOM
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
API
Table of Contents
-
tossr
- Parameters
-
Config
- Properties
-
Eval
- Parameters
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
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
-
dom
object The DOM object *