Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sequencemedia/react-router-redux-render
Render isomorphic React + React Router + Redux apps and components in Node
https://github.com/sequencemedia/react-router-redux-render
isomorphic react react-router redux render
Last synced: 2 months ago
JSON representation
Render isomorphic React + React Router + Redux apps and components in Node
- Host: GitHub
- URL: https://github.com/sequencemedia/react-router-redux-render
- Owner: sequencemedia
- Created: 2019-05-28T15:17:06.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-04-13T03:59:06.000Z (9 months ago)
- Last Synced: 2024-04-14T01:02:47.535Z (9 months ago)
- Topics: isomorphic, react, react-router, redux, render
- Language: JavaScript
- Homepage:
- Size: 3.33 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# react-router-redux-render
Render isomorphic _React_ apps and components in Node.
- Using _React Router_
- With Redux_Compatible with React Router 5._
An example implementation 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 = 3000const {
configureStore
} = require('./path/to/store')const store = configureStore()
const routes = require('./path/to/routes')
const {
renderToString
} = require('react-router-redux-render')app.get('/', ({ url: { path: pathname = '/' } }, res) => res.send(renderToString(store, routes, pathname)))
app.listen(port, () => console.log(`Express ${port}`))
```If React Router matches the `pathname` to a `` then `renderToString` returns a string.
If `renderToString` encounters an error then it throwa a `500 Internal Server Error`.
If `renderToString` cannot match the `pathname` to a `` then it throws a `404 Not Found`.
## In this package
`react-router-redux-render` exports three functions:
1. `renderToString`
2. `renderToStaticMarkup`
3. `render``renderToString` generates `