An open API service indexing awesome lists of open source software.

https://github.com/sequencemedia/react-render

Render isomorphic React apps and components in Node
https://github.com/sequencemedia/react-render

isomorphic react render

Last synced: 5 months ago
JSON representation

Render isomorphic React apps and components in Node

Awesome Lists containing this project

README

          

# react-render

Render isomorphic _React_ apps and components in Node.

An example implementation of the companion package `@sequencemedia/react-router-redux-render` can be found in [react-router-pagination-io](http://github.com/sequencemedia/react-router-pagination-io.git).

## Example

In Express:

```javascript
const express = require('express')

const app = express()
const port = 3000

const {
renderToString
} = require('react-render')

const App = require('./path/to/react/app')

app.get('/', (req, res) => res.send(renderToString(App)))

app.listen(port, () => console.log(`Express ${port}`))
```

If `renderToString` encounters an error then it throws a `500 Internal Server Error`. Otherwise, it returns a string.

You can supply `App` with `props` using the second argument:

```javascript
renderToString(App, {})
```

(Since this is not a _Redux_ app you are likely to use `props`.)

## In this package

`react-render` exports three functions:

1. `renderToString`
2. `renderToStaticMarkup`
3. `render`

`renderToString` generates `