Create a Website Using Laravel and React

In this tutorial, we will show you how to build a complete website using Laravel and React.

Laravel is a very powerful PHP web application framework that provides a structure and starting point for creating a web application. While React is a Javascript library for building interactive UI components or user interfaces.

You should have some familiarity with HTML, Javascript and PHP but you should be able to follow along even if you are coming from a different programming language.

Follow the steps below to complete this tutorial:

Create a Laravel Project

The first thing you need to do is create a new laravel project using Composer.

If you do not have Composer installed, please visit How to install Composer .

To create a Laravel project, use composer create-project --prefer-dist laravel/laravel command followed by your project name. Example given below:

composer create-project --prefer-dist laravel/laravel my-website

Laravel with React

Laravel provides a basic starting point using Bootstrap, React/Vue. By default, Laravel uses NPM to install these frontend packages.

Now, navigate to the newly created project folder:

cd my-website

Next, install laravel/ui using Composer:

composer require laravel/ui

Now, to make your Laravel application to use React UI run the following command one by one:

php artisan ui react

npm install

Run the Application

From inside your project root folder, run the following command to start your application:

php artisan serve

To view quick changes on your UI, use the following command on a separate terminal:

npm run watch

Now, open http://localhost:8000 on your browser.