https://github.com/zv3/sjs-react-server-prerender
japgolly's scalajs-react running on a remote nodejs environment for server side rendering (proof of concept)
https://github.com/zv3/sjs-react-server-prerender
Last synced: 11 months ago
JSON representation
japgolly's scalajs-react running on a remote nodejs environment for server side rendering (proof of concept)
- Host: GitHub
- URL: https://github.com/zv3/sjs-react-server-prerender
- Owner: zv3
- License: apache-2.0
- Created: 2016-02-06T20:37:46.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-11-06T06:10:56.000Z (over 9 years ago)
- Last Synced: 2025-03-12T10:12:12.274Z (over 1 year ago)
- Language: Scala
- Homepage:
- Size: 8.79 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sjs-react-server-prerender
Proof of concept of a simple pagination component built with jagpolly's [scalajs-react](https://github.com/japgolly/scalajs-react), performing in node.js for server side rendering using lihaoyi's [upickle](https://github.com/lihaoyi/upickle-pprint) library (remote rendering using expressjs).
So essentially this is just about pre-rendering components built with Scala.js on the server using a node environment. The main idea to this is to create a backend service running in nodejs to render React components (built with Scala.js) to their initial HTML code using the [`ReactDOMServer.renderToString()`](https://facebook.github.io/react/docs/react-dom-server.html#rendertostring) method. The returned HTML markup could then be sent to a JVM app (i.e. Play Framework) which in turn could send that data back to the user's browser.
#### Steps to reproduce ####
Run:
`sbt fastOptJS && npm i && node server.js`
Hit your browser to [http://localhost:3000/pagination](http://localhost:3000/pagination) and check the generated source HTML code.