rtorc's avatar
Level 1

React and Angular 2

Hi, I've been learning Angular 2 and React. Not sure if I should learn Flux or Redux yet, but anyway it looks like Angular 2 and or react want you to turn your entire site into a SPA (single page app). I used to use Angular 1 and sprinkle some angular components on sites with no problem and keep using Laravel routes and views. Now it looks like we should only use Laravel routes for APIs and one index route for the SPA page.

Is anyone using Angular 2 or React on a large scale site? Should we be using Laravel views and Routes or should all web apps now be SPAs

0 likes
8 replies
jusahah87's avatar

I can answer the last part of your question:

should all web apps now be SPAs

No. God no.

EDIT: To elaboreate... SPA works pretty well for apps which are meant to remain open/active for long periods of time.

Twitter, for instance. Or Instagram.

These are typically opened once (the initial download), then the user spents next fifteen hours surfing inside the app. It makes sense (from purely utilitaristic view point) to avoid downloading views from server again and again. Plus SPAs look flashy and shit.

Most large-scale sites are nothing like Twitter, though. Take a Wikipedia, for example. User comes in, reads one article, and leaves. It makes little sense to download heavy JS code for that.

rtorc's avatar
Level 1

it seems like it when your read all the docs for Angular 2 and React.

primordial's avatar

@rtorc I believe Angular/2 is an enterprise application and should only be used as part of a decoupled SPA solution. I'm developing in Angular/2 with approximately 45 back end services.

If you want a halfway house then I believe Vue is probably better suited. I have very limited experience of React.

1 like
rtorc's avatar
Level 1

So far React is winning me over imho over Vue and Angular 2.

I just need to figure out how i can integrate React components over my entire site without turning the whole site into a SPA

jusahah87's avatar

@rtorc

If Angular docs jumped from a bridge, would you follow?

I mean no offense, but Angular/React docs are - of course - written by developers who believe in SPA-centric world. Their view is very biased. I am not saying it is a wrong view, but it is definitely a biased one.

rtorc's avatar
Level 1

@ jusahah87 I'm asking the question here before i jump off any bridge. Of course their view is biased (duh), but I don't see any tutorials or docs showing how to use Angular 2 or React in a non SPA site.

I would love to use react components on my site without turning the entire site to a SPA and keep my route logic in Laravel

primordial's avatar

@rtorc From what I know about Angular/2 and what you have said about React why swim against the tide? Either jump off the bridge or perhaps choose Vue(?) I work for a large company with large systems. We jumped; And whilst we nearly drowned a few times we're still here and I am loving every minute of the SPA experience.

Decoupling has always been a preferred approach. From micro-services to packages through front-end frameworks; Are they not just implementations of a long standing principle taking advantage of the latest technologies?

If an SPA is overkill or the learning curve inconvenient wait for another opportunity.

rtorc's avatar
Level 1

well i found a solution to my answer. To use Angular 2 or React without building the entire app as SPA i will need to use SSR (server side rendering)

Found this great article here https://scotch.io/tutorials/react-on-the-server-for-beginners-build-a-universal-react-and-node-app

This is really cool and it looks like my time spent learning Node this summer wasn't wasted. In fact it looks like everything is going to javascript eventually. To build a SSR React or Angular App with Laravel doesn't make any sense, so it looks like Javascript will eventually beat out PHP, Rails for building web applications.

Please or to participate in this conversation.