Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Valen_y's avatar

Using Laravel with React

Hi everyone, newbie here.

I just want to ask how I can integrate the two technologies mentioned above into an existing project. I’ve recently joined a very legacy project that used Laravel 5.5 as a semi-backend, along with a pseudo-frontend written in Smarty, which also functions as a backend itself. Yes, it’s a very disorganized project.

Recently, we’ve accomplished some major upgrades to reorganize the project, we're now in Laravel 11, but now we’re facing a dilemma: whether to use Blade/Livewire views or React. We're oriented towards using React because of the benefits of JavaScript but here’s the catch: we cannot use the Laravel Breeze + React approach because we have a mobile app, and as far as I know, that setup requires using Inertia, which doesn’t use APIs—a must for us due to the app.

I have no experience with JS frameworks and just wanted to know how I can address this problem. Specifically, how can I “glue” Laravel and React together? Additionally, is it possible to use a single repository for both the backend and frontend, instead of having separate repositories for each?.

Thanks in advance, and I apologize if my question breaks any forum rules.

0 likes
4 replies
jamesbuch79's avatar

You can use Laravel as an API. Use it as a back end, and create an ordinary React front end that authenticates using JWTs or similar, whatever the mobile app is using. But why not use Inertiajs and React + Breeze, if you separate the routes entirely? Keep the API in /routes/api.php, and have a new front end with routes in routes/web.php. Keep everything separate and versioned for your API, let the mobile app keep using it, and use whatever you like for a new front end responding to routes in web.php. You can use a single repository if you want, I assume you're talking about a monorepo?

Valen_y's avatar

@jamesbuch79 Thanks for your reply.

I would say, from my inexperience using JS frameworks, that I would prefer to use the Laravel Breeze + React + Inertia approach, for its simplicity, but there is, as far as my knowledge allows me, the problem of having to use two routes to define essentially the same thing. That is, if in a React view, a web route, I want to index an entire model then I could not use the definition written for that request in the API route but would basically have to create a new route or copy the same logic to place it in some way that Inertia can serve it. I don't know if what I'm writing makes much sense but it's what I infer happens with that approach from what I've been reading about Inertia. And yes, when I say 'single repository' I mean monorepo.

rezanurfachmi's avatar

@Valen_y If Laravel Breeze is the problem, have you considered using Laravel Fortify combined with Sanctum?

martinbean's avatar

@valen_y What’s the big reason and push to use JavaScript if you’re not really experienced with JavaScript frameworks? Why not just stick to Blade templates if that’s what you and the team are comfortable and experienced with?

There’s nothing worse than introducing a technology that no one is familiar or sufficiently experienced with into a mature project, because you get so far, realise the code is crap the more you do learn about whatever technology, and then you end up with a project with code you desperately want to re-factor but can’t because you don’t have the time, and it becomes a project no one ends up liking working with because you’re all just adding and adding to a codebase you all hate.

1 like

Please or to participate in this conversation.