DEV Community

Saroj Pradhan
Saroj Pradhan

Posted on

What is Inertiajs? No API required to connect Backend and Frontend?

Inertia.js is an approach that allows you to build single-page applications (SPAs) using server-side rendering and traditional server-side routing. In other words, it allows you to build SPAs using just PHP (Laravel), Ruby (Rails), or any other server-side language, and client-side framework such as React, Vuejs without worrying about maintaining two different repository, two different domain to host backend and frontend separately.

Inertia has no client-side routing, nor does it require an API. Simply you can build controllers and page views in easier way.

One of the easiest methods to get started with React/Vue, Inertiajs and Laravel is by installing Laravel/breeze scaffolding:

  • Start a Laravel Project
composer create-project laravel/laravel laravel-inertia-react
Enter fullscreen mode Exit fullscreen mode
  • Install laravel/breeze in your laravel project.
composer require laravel/breeze --dev
Enter fullscreen mode Exit fullscreen mode
  • Then install the frontend scaffolding as per your desire
php artisan breeze:install vue

# Or...

php artisan breeze:install react

php artisan migrate
npm install
npm run dev
Enter fullscreen mode Exit fullscreen mode
  • Run server to view the Laravel/breeze default authentication scaffolding.
php artisan serve
Enter fullscreen mode Exit fullscreen mode

Note: Inertia is not appropriate for those who value SEO, even though inertia make life easier to integrate frontend and backend.

Useful links: Inertiajs, Laravel-breeze

If you liked this post please leave a reaction/comment.

Read More in BlazeCodes.com

Top comments (0)