Follow

#ReactJS next.js laravel question 

Alright nerds. Help me lazyweb this:

Let's say I want to get some SSR React stuff happening, but the whole backend is a Laravel API I ain't rewriting.

Currently React (client-side) just pings the api and the various components just fill up when they're ready.

If I wanted to SSR this sort of thing, do I do that with NextJS and have something like a node server acting as a bridge, or does Next work with Laravel without an extra hop in between.

Or do I actually have to rewrite the api if I wanna do this?

Or are there even better options my feeble mind hasn't thought of?

#ReactJS next.js laravel question 

@JacksonBates I'm looking into next right now, I'll take a look tomorrow and see what I can find out. But anyone experience with next will have better info than me

#ReactJS next.js laravel question 

@JacksonBates the most straightforward way I see so far is implement getServerSideProps() to have Next running on a Node server in turn make the API request to Laravel: nextjs.org/docs/basic-features

If Next and Laravel are on the same server or VPS the latency added would probably not be too bad.

Someone may have made a way to integrate Next and Laravel even more tightly, but would want to be sure any such tool is well-maintained

#ReactJS next.js laravel question 

@JacksonBates if you are just making a fetch call, no need to rewrite anything. Next has a function getServerSideProps that you export from the page. In there is where you can hit your api and then return the data as props for the page component to consume.

#ReactJS next.js laravel question 

@CobyPear hmm, so I can consume the laravel as an API like do already.

Is there any benefit to using next in that way instead of just another client side react implementation? Or is getServerSideProps a part of SSR I don't understand yet?

#ReactJS next.js laravel question 

@JacksonBates oh it’s possible I misunderstood the first post. getServerSideProps enables the SSR on the route using it.

#ReactJS next.js laravel question 

@CobyPear I'll be a little less lazyweb later and dig into it - just wanted to see if it was worth my time at all.

Thanks for the input

#ReactJS next.js laravel question 

@JacksonBates no worries!! I personally like the meta frameworks just to enable filesystem based routing! Not everyone’s cup of tea tho.

Sign in to participate in the conversation
Aus.Social

Welcome to thundertoot! A Mastodon Instance for 'straya