Skip to content
This repository has been archived by the owner on Oct 10, 2019. It is now read-only.

express and server rendering #14

Open
darul75 opened this issue Apr 15, 2015 · 0 comments
Open

express and server rendering #14

darul75 opened this issue Apr 15, 2015 · 0 comments

Comments

@darul75
Copy link

darul75 commented Apr 15, 2015

Hi again,

I have tried using generated react app to be rendered on server side, by instance with Express with no success...

Would you mind do provide a simple example.

My idea was to use generated ES5 js sources instead of ES6 not handled quite well with Express.
Then see if bundle can be digest in server express code to call Application react root node.

var express = require('express')
  , app = express()
  , React = require('react/addons')
  , components = require('TODO'); // js react component file ? app.js ?

var Application = React.createFactory(components.Application);  

// application
app.get("/*", function(req, res) {
  res.contentType = "text/html; charset=utf8";
  var html = Application();
  res.end(html);  
});


var port = +(process.env.PORT || 8080);
app.listen(port, function() {
  console.log("Server listening on port " + port);
});

I have looked into react-starter but looks complicated and not ES6 by default

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant