react-laravel
react-laravel copied to clipboard
Best way to connect laravel routes and react-router?
Loving this package... got this all working in an app.
One question I have is how would you hook up the routing. I see 2 options.
- Keep client-side routing on the client - and only use Laravel for api stuff or full page reloads
- Pass Laravel routes to the react-router if they don't exist (404)
Thoughts?
Huum, for now I would use the first option, the second seems wrong.
But, as I said, it's for now, I'm planning to create a @react_router
directive soon !
That sounds pretty cool... why would you write your react routes in blade though?
Actually I wouldn't, the directive would mount and run the router, as the @react_component
do for components, I'm still thinking about it, suggestions are welcome.
I do think connecting the routing somehow would be pretty awesome. Just thinking myself how I would like that to work.
Hey, @brenelz, sorry by the delay, I've been busy ! I'm thinking about building something using laroute, what do you think ?
@brenelz good direction we need something like isomorphic app .
send to client all route needed for the page if javascript fallback or client going to other page route it from the server.
@talyssonoc I like the laroute idea. For me, the real appeal of a client-side app is the quick response of the UI, as the app only gets page specific (often Json) data from the server, following navigation. Would this allow us to access important Laravel features like route specific middleware, and route bindings?
Hi, @karlonauger, as it would just generate the URL for the route I would say yes, it would allow access to middlewares and so on. I think it would let React just make ajax requests to the given URL and, there, you can say what will be sent to the client (something like this pjax example: https://github.com/defunkt/jquery-pjax#server-side), what do you think ?
That sounds great! It would save me a ton of time trying to re-design, and duplicate client-side authentication.
Hey there, any update on this ? Cheers ;)
Do you know how to access direct a permanent link create by react creating the route in laravel?