Key takeaways: #
- Laravel and React work great together, forming a false dichotomy. You can use them together to get the best of both worlds.
- Laravel is a comprehensive backend framework, offering a range of features from database layer to routing, while also providing frontend capabilities with its templating language.
- React is a popular client-side library for building user interfaces and providing rich client-side interactivity.
- Inertia is a powerful JavaScript library that bridges the gap between Laravel and React/Vue, allowing you to build fully-featured single-page applications without the need for API endpoints or client-side routing.
Laravel: A versatile backend framework #
- Laravel is a backend framework with its foundation in server-side operations.
- It encompasses a multitude of features, including database layer, models, cron jobs, cues, caching, emails, authentication, and routing.
- Additionally, Laravel offers a full templating language for front-end development, complete with components, layouts, slots, loops, variables, and more.
- However, it is worth noting that for rich client-side interactivity, you might need to incorporate another tool, such as React or Vue.js, alongside Laravel.
React: A client-side library for rich interactivity #
- React, along with Vue.js, is a client-side library focused on building user interfaces and offering rich client-side interactivity.
- While React started as a fully client-side tool, it has been slowly expanding its reach to the backend with meta frameworks like Next.js, which allow running React server components on the server.
- However, other tools like Remix, which have been referred to as 'center stack' frameworks, primarily focus on bridging the gap between the frontend and backend while leaving the backend structure for the developer to figure out.
Inertia: Bridging Laravel and React/Vue #
- Inertia is an outstanding JavaScript library that sits in the middle of your stack, bridging the gap between Laravel and React/Vue.
- With Inertia, you can build fully-featured, JavaScript-heavy frontends while still utilizing Laravel as your backend.
- Inertia eliminates the need for API endpoints and client-side routing as it intercepts the routing on the Laravel layer.
- Inertia also offers adapters for various backend and frontend frameworks, and features like partial reloads, static site generation, form requests, and validation.
- By using Laravel and React/Vue in conjunction with Inertia, you can eliminate the network chasm and create clear boundaries between your backend and frontend, making it easier to maintain and develop your application.
-
"Inertia is the greatest JavaScript library that you've never heard of."
Summary for: Youtube