EDIT in Feb 2022: I posted this solution when the latest Laravel was V5 and react-router was V4. There could be a better solution now, because both Laravel and react-router evolved a lot since then
==================================================
How about using <HashRouter>?
E.g.
import React from 'react';
import {
HashRouter,
Route,
Link
}from 'react-router-dom';
import Profile from './Profile';
export default class App extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<HashRouter>
<Link to="/profile" replace>Profile</Link>
<Route path="/profile" component={Profile}/>
</HashRouter>
);
}
}
In Laravel's router...
Route::get('/', function(){
return view('index'); //This view is supposed to have the react app above
});
With HashRouter, your client side routing is done with # (Fragment Identifier), which is not read by Laravel's routing (i.e. server side routing)
Upon arriving this page, the URL is /.
Clicking the link will make the URL /#/profile and the component will appear.
After that, if you refresh the page, you wont' see the Route not exist error. This is because, from Laravel's perspective, the URL is still /. (The component Profile still remains there.)
https://reacttraining.com/react-router/web/api/HashRouter
Hope my explanation is clear.