tossr
v1.4.2
Published
Universal SSR
Downloads
10,897
Readme
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
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-aliveoptions
Partial<Config>? Options
Config
Type: object
Properties
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
Eval
Called before/after the app script is evaluated
Type: Function
Parameters
dom
object The DOM object *
Party vector created by gstudioimagen - www.freepik.com