Home > Net >  How to link laravel project with reactJs project together
How to link laravel project with reactJs project together

Time:11-03

my main idea is to have two separate projects. One for backend that uses laravel and one for frontend that uses react js. Is there a way that i can link them together? i googled the answer, but i couldn't find anything helpful.

CodePudding user response:

Use ziggy library .It will map all your laravel routes names an their url(s).

Ziggy provides a JavaScript route() helper function that works like Laravel's, making it easy to use your Laravel named routes in JavaScript.

CodePudding user response:

Make root folder like website then open-shell inside of website folder in enter commands:

composer create-project laravel/laravel LaravelAPIs

then for react client:

npx create-react-app ReactClient

then your website folder will contain two folders

/website
    /LaravelAPIs
    /ReactClient

then run laravel app on port 8000 and react app run on 3000 port

/website/LaravelAPIs/>php artisan serve
/website/ReactClient/>npm start
  • Related