Combining Vue.js with Inertia.js gives you the best of both worlds — server-side routing with client-side rendering. No API needed.
Why Inertia.js?
Inertia bridges the gap between your Laravel backend and Vue frontend. You write your controllers and routes as usual, and Inertia handles the rest.
Example: A Simple Page
// Pages/Users/Index.vue
export default {
props: {
users: Array,
},
}
// Routes
Route::get('/users', function () {
return Inertia::render('Users/Index', [
'users' => User::all(),
]);
});
This approach keeps your code clean and eliminates the need for API endpoints and axios calls for simple page navigation.