1.4.2 • Published 5 years ago
tossr v1.4.2
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
templatestring Html template (or path to a HTML template).scriptstring Bundled JS app (or path to bundled bundle JS app).urlstring Path to render. Ie. /blog/breathing-oxygen-linked-to-staying-aliveoptionsPartial<Config>? Options
Config
Type: object
Properties
hoststring hostname to use while rendering. Defaults to http://jsdom.ssreventNamestring event to wait for before rendering app. Defaults to 'app-loaded'beforeEvalEval Executed before script is evaluated.afterEvalEval Executed after script is evaluated.silentboolean Don't print timestampsinlineDynamicImportsboolean required for apps with dynamic importstimeoutnumber required for apps with dynamic importsdevboolean disables caching of inlinedDynamicImports bundleerrorHandlerfunction
Eval
Called before/after the app script is evaluated
Type: Function
Parameters
domobject The DOM object *
Party vector created by gstudioimagen - www.freepik.com