--- name: inertia-vue-development description: >- Develops Inertia.js v2 Vue client-side applications. Activates when creating Vue pages, forms, or navigation; using ,
, useForm, or router; working with deferred props, prefetching, or polling; or when user mentions Vue with Inertia, Vue pages, Vue forms, or Vue navigation. --- @php /** @var \Laravel\Boost\Install\GuidelineAssist $assist */ @endphp # Inertia Vue Development ## When to Apply Activate this skill when: - Creating or modifying Vue page components for Inertia - Working with forms in Vue (using `` or `useForm`) - Implementing client-side navigation with `` or `router` - Using v2 features: deferred props, prefetching, or polling - Building Vue-specific features with the Inertia protocol ## Documentation Use `search-docs` for detailed Inertia v2 Vue patterns and documentation. ## Basic Usage ### Page Components Location Vue page components should be placed in the `resources/js/Pages` directory. ### Page Component Structure Important: Vue components must have a single root element. @verbatim @boostsnippet("Basic Vue Page Component", "vue") @endboostsnippet @endverbatim ## Client-Side Navigation ### Basic Link Component Use `` for client-side navigation instead of traditional `` tags: @boostsnippet("Inertia Vue Navigation", "vue") @endboostsnippet ### Link with Method @boostsnippet("Link with POST Method", "vue") @endboostsnippet ### Prefetching Prefetch pages to improve perceived performance: @boostsnippet("Prefetch on Hover", "vue") @endboostsnippet ### Programmatic Navigation @boostsnippet("Router Visit", "vue") @endboostsnippet ## Form Handling @if($assist->inertia()->hasFormComponent()) ### Form Component (Recommended) The recommended way to build forms is with the `` component: @verbatim @boostsnippet("Form Component Example", "vue") @endboostsnippet @endverbatim ### Form Component With All Props @verbatim @boostsnippet("Form Component Full Example", "vue") @endboostsnippet @endverbatim @if($assist->inertia()->hasFormComponentResets()) ### Form Component Reset Props The `` component supports automatic resetting: - `resetOnError` - Reset form data when the request fails - `resetOnSuccess` - Reset form data when the request succeeds - `setDefaultsOnSuccess` - Update default values on success Use the `search-docs` tool with a query of `form component resetting` for detailed guidance. @verbatim @boostsnippet("Form with Reset Props", "vue") @endboostsnippet @endverbatim @else Note: This version of Inertia does not support `resetOnError`, `resetOnSuccess`, or `setDefaultsOnSuccess` on the `` component. Using these props will cause errors. Upgrade to Inertia v2.2.0+ to use these features. @endif Forms can also be built using the `useForm` composable for more programmatic control. Use the `search-docs` tool with a query of `useForm helper` for guidance. @endif ### `useForm` Composable @if($assist->inertia()->hasFormComponent() === false) For Inertia v2.0.x: Build forms using the `useForm` composable as the `` component is not available until v2.1.0+. @else For more programmatic control or to follow existing conventions, use the `useForm` composable: @endif @verbatim @boostsnippet("useForm Composable Example", "vue") @endboostsnippet @endverbatim ## Inertia v2 Features ### Deferred Props Use deferred props to load data after initial page render: @verbatim @boostsnippet("Deferred Props with Empty State", "vue") @endboostsnippet @endverbatim ### Polling Automatically refresh data at intervals: @verbatim @boostsnippet("Polling Example", "vue") @endboostsnippet @endverbatim ### WhenVisible (Infinite Scroll) Load more data when user scrolls to a specific element: @verbatim @boostsnippet("Infinite Scroll with WhenVisible", "vue") @endboostsnippet @endverbatim ## Server-Side Patterns Server-side patterns (Inertia::render, props, middleware) are covered in inertia-laravel guidelines. ## Common Pitfalls - Using traditional `` links instead of Inertia's `` component (breaks SPA behavior) - Forgetting that Vue components must have a single root element - Forgetting to add loading states (skeleton screens) when using deferred props - Not handling the `undefined` state of deferred props before data loads - Using `` without preventing default submission (use `` component or `@submit.prevent`) - Forgetting to check if `` component is available in your Inertia version