Granze / react-starterify

A minimal React JS application starter kit
http://granze.github.io/react-starterify/
665 stars 71 forks source link

Server side code #34

Closed ghost closed 8 years ago

ghost commented 8 years ago

Hi everyone. I really love the kit and I want to use it for my next application, so I'm still experimenting. I'm kind of new to nodejs. Any idea how I could include server side code (react, mongoose) within react starterify. Thanks

Granze commented 8 years ago

Hi, honestly I haven't used the server rendering in React yet, so I'm not an expert on this topic. I found this guide that may helps.

ghost commented 8 years ago

Hi. Thank you for your response. This is not an actual issue but I couldn't find any other way to communicate with you. By server side code I don't mean server side rendering using react. What I mean is having an API on the same code base. Right now the kit runs a server on localhost:3000 if I'm correct. My question is how can I have for example a server.js running express for my API calls. I know that probably this is not how and why the kit was designed for, but I don't know if that would be a could idea. Thank you for your time!

Granze commented 8 years ago

Oh I see. Well, there are really many options here. Relay is the way FB do that but, of course, you need to use GraphQL.

If you need a simple way to get some data from the server, you can do it in the componentDidMount function as explained here.

For more complex (real world) applications, you will probably use one of the available Flux implementations like Redux. This is obviously not the only way to do it and there are lots of discussions on the topic, like this one.

React Starterify, wants to be minimal and less opinionated as possible, for that reason, it doesn't include any of these solutions.