I am trying to build a simple webapp, just to learn something new and I've decided to learn react js. I have implemented some backend in java and spring, but I don't really know how to integrate it with flux architecure. Is it even possible or should I change my backend ( I'm using spring mvc and flux has different approach)? I was searching a lot, but almost every example I found is a full js application or using rails as a backend which I don't know at all.
-
1The flux pattern doesn't define web server interactions. https://facebook.github.io/flux/. I'd suggest you try a few of the simpler NodeJs examples and see how data is handled in some cases. Ultimately it's up to you though. Flux doesn't fit every need. – WiredPrairie Apr 04 '15 at 12:33
-
Does your backend support `GET` and `POST` requests? So if I go to `localhost:port/my_data` do I get data? – Keith Yong Apr 05 '15 at 13:58
1 Answers
If you want to keep an existing back end, and yet run React + Flux on the server for server-side rendering, I suggest you take a look at the example from Soundclound, written by @zertosh:
example: https://github.com/zertosh/ssr-demo-kit
video: https://vimeo.com/108488724
In their app, they are running Scala on the back end, and they spin up a Nashorn-based script runner to flush an initial action through the application, produce the HTML and pass it all to the client. Then the client takes over.
You'll need some XHR endpoints too, when you want to save data back to the server, but that's all just normal GET/POST URL params to JSON stuff.
All that seems like a bit much just to learn React. You might be better off while learning to just send down some JSON and let the client do the initial rendering, saving the server-side rendering stuff for when you feel comfortable with the client side code.

- 12,658
- 4
- 28
- 27