You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: frontend.md
+21-31
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@
5
5
-[PHP and Blade](#php-and-blade)
6
6
-[Livewire](#livewire)
7
7
-[Starter Kits](#php-starter-kits)
8
-
-[Using Vue / React](#using-vue-react)
8
+
-[Using React or Vue](#using-react-or-vue)
9
9
-[Inertia](#inertia)
10
10
-[Starter Kits](#inertia-starter-kits)
11
11
-[Bundling Assets](#bundling-assets)
@@ -104,19 +104,19 @@ If you're new to Laravel, we recommend getting familiar with the basic usage of
104
104
105
105
If you would like to build your frontend using PHP and Livewire, you can leverage our [Livewire starter kit](/docs/{{version}}/starter-kits) to jump-start your application's development.
106
106
107
-
<aname="using-vue-react"></a>
108
-
## Using Vue / React
107
+
<aname="using-react-or-vue"></a>
108
+
## Using React or Vue
109
109
110
-
Although it's possible to build modern frontends using Laravel and Livewire, many developers still prefer to leverage the power of a JavaScript framework like Vue or React. This allows developers to take advantage of the rich ecosystem of JavaScript packages and tools available via NPM.
110
+
Although it's possible to build modern frontends using Laravel and Livewire, many developers still prefer to leverage the power of a JavaScript framework like React or Vue. This allows developers to take advantage of the rich ecosystem of JavaScript packages and tools available via NPM.
111
111
112
-
However, without additional tooling, pairing Laravel with Vue or React would leave us needing to solve a variety of complicated problems such as client-side routing, data hydration, and authentication. Client-side routing is often simplified by using opinionated Vue / React frameworks such as [Nuxt](https://nuxt.com/) and [Next](https://nextjs.org/); however, data hydration and authentication remain complicated and cumbersome problems to solve when pairing a backend framework like Laravel with these frontend frameworks.
112
+
However, without additional tooling, pairing Laravel with React or Vue would leave us needing to solve a variety of complicated problems such as client-side routing, data hydration, and authentication. Client-side routing is often simplified by using opinionated React / Vue frameworks such as [Next](https://nextjs.org/) and [Nuxt](https://nuxt.com/); however, data hydration and authentication remain complicated and cumbersome problems to solve when pairing a backend framework like Laravel with these frontend frameworks.
113
113
114
114
In addition, developers are left maintaining two separate code repositories, often needing to coordinate maintenance, releases, and deployments across both repositories. While these problems are not insurmountable, we don't believe it's a productive or enjoyable way to develop applications.
115
115
116
116
<aname="inertia"></a>
117
117
### Inertia
118
118
119
-
Thankfully, Laravel offers the best of both worlds. [Inertia](https://inertiajs.com) bridges the gap between your Laravel application and your modern Vue or React frontend, allowing you to build full-fledged, modern frontends using Vue or React while leveraging Laravel routes and controllers for routing, data hydration, and authentication — all within a single code repository. With this approach, you can enjoy the full power of both Laravel and Vue / React without crippling the capabilities of either tool.
119
+
Thankfully, Laravel offers the best of both worlds. [Inertia](https://inertiajs.com) bridges the gap between your Laravel application and your modern React or Vue frontend, allowing you to build full-fledged, modern frontends using React or Vue while leveraging Laravel routes and controllers for routing, data hydration, and authentication — all within a single code repository. With this approach, you can enjoy the full power of both Laravel and React / Vue without crippling the capabilities of either tool.
120
120
121
121
After installing Inertia into your Laravel application, you will write routes and controllers like normal. However, instead of returning a Blade template from your controller, you will return an Inertia page:
122
122
@@ -137,41 +137,31 @@ class UserController extends Controller
137
137
*/
138
138
public function show(string $id): Response
139
139
{
140
-
return Inertia::render('Users/Profile', [
140
+
return Inertia::render('users/show', [
141
141
'user' => User::findOrFail($id)
142
142
]);
143
143
}
144
144
}
145
145
```
146
146
147
-
An Inertia page corresponds to a Vue or React component, typically stored within the `resources/js/Pages` directory of your application. The data given to the page via the `Inertia::render` method will be used to hydrate the "props" of the page component:
147
+
An Inertia page corresponds to a React or Vue component, typically stored within the `resources/js/pages` directory of your application. The data given to the page via the `Inertia::render` method will be used to hydrate the "props" of the page component:
<p>Hello {user.name}, welcome to Laravel and Inertia.</p>
159
+
</Layout>
160
+
)
161
+
}
172
162
```
173
163
174
-
As you can see, Inertia allows you to leverage the full power of Vue or React when building your frontend, while providing a light-weight bridge between your Laravel powered backend and your JavaScript powered frontend.
164
+
As you can see, Inertia allows you to leverage the full power of React or Vue when building your frontend, while providing a light-weight bridge between your Laravel powered backend and your JavaScript powered frontend.
0 commit comments