Render HTML from any SPA.
npm i tossr
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)
Renders an HTML page from a HTML template, an app bundle and a path
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-aliveoptions
Partial<Config>? Options
Type: object
host
string hostname to use while rendering. Defaults to http://jsdom.ssreventName
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 timestampsinlineDynamicImports
boolean required for apps with dynamic importstimeout
number required for apps with dynamic importsdev
boolean disables caching of inlinedDynamicImports bundleerrorHandler
function
Called before/after the app script is evaluated
Type: Function
dom
object The DOM object *