Skip to content
Riot.js node Server Side Rendering
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src updated: dependencies and clean up a bit the code Jun 4, 2019
test updated: dependencies and clean up a bit the code Jun 4, 2019
.eslintrc First commit Feb 21, 2019
.gitignore render input value property as html attribute May 26, 2019
.travis.yml added: travis setup May 1, 2019
LICENSE
README.md updated: titles May 1, 2019
package-lock.json 4.1.0 Jun 4, 2019
package.json 4.1.0 Jun 4, 2019

README.md

ssr

Riot module to render riot components on the server

Build Status

NPM version NPM downloads MIT License

Installation

npm i -S riot @riotjs/compiler @riotjs/ssr

Usage

render - to render only markup

You can simply render your components markup as it follows:

import MyComponent from './my-component.riot'
import render from '@riotjs/ssr'

const html = render('my-component', MyComponent, { some: 'initial props' })

fragments - to render html and css

You can also extract the rendered html and css separately using the fragments function:

import MyComponent from './my-component.riot'
import {fragments} from '@riotjs/ssr'

const {html, css} = fragments('my-component', MyComponent, { some: 'initial props' })

register - to load riot components in node

If you only want load your components source code in a node environement you just need to register the riot loader hook:

import register from '@riotjs/ssr/register'

import MyComponent from './my-component.riot' // It will fail

// from now on you can load `.riot` tags in node
const unregister = register()

import MyComponent from './my-component.riot' // it works!

// normally you will not need to call this function but if you want you can unhook the riot loader
unregister()
You can’t perform that action at this time.