--- name: inertia-react-development description: >- Develops Inertia.js v1 React client-side applications. Activates when creating React pages, forms, or navigation; using Link or router; or when user mentions React with Inertia, React pages, React forms, or React navigation. --- @php /** @var \Laravel\Boost\Install\GuidelineAssist $assist */ @endphp # Inertia React Development ## When to Apply Activate this skill when: - Creating or modifying React page components for Inertia - Working with forms in React (using `router.post` or `useForm` if available) - Implementing client-side navigation with `` or `router` - Building React-specific features with the Inertia protocol ## Documentation Use `search-docs` for detailed Inertia v1 React patterns and documentation. ## Basic Usage ### Page Components Location React page components should be placed in the `resources/js/Pages` directory. ### Page Component Structure @boostsnippet("Basic React Page Component", "react") export default function UsersIndex({ users }) { return (

Users

) } @endboostsnippet ### Client-Side Navigation Use `` for client-side navigation (not `` tags): @boostsnippet("Inertia React Navigation", "react") import { Link } from '@inertiajs/react' Home Users View User @endboostsnippet ### Link With Method @boostsnippet("Link with POST Method", "react") import { Link } from '@inertiajs/react' Logout @endboostsnippet ### Programmatic Navigation @boostsnippet("Router Visit", "react") import { router } from '@inertiajs/react' function handleClick() { router.visit('/users') } // Or with options router.visit('/users', { method: 'post', data: { name: 'John' }, onSuccess: () => console.log('Success!'), }) @endboostsnippet ## Form Handling ### Using `router.post` @boostsnippet("Form With router.post", "react") import { router } from '@inertiajs/react' import { useState } from 'react' export default function CreateUser() { const [values, setValues] = useState({ name: '', email: '', }) const [processing, setProcessing] = useState(false) function handleSubmit(e) { e.preventDefault() setProcessing(true) router.post('/users', values, { onFinish: () => setProcessing(false), }) } return (
setValues({ ...values, name: e.target.value })} /> setValues({ ...values, email: e.target.value })} />
) } @endboostsnippet ### Using `useForm` Hook (If Available) Check the Inertia documentation to confirm if `useForm` is available in your version: @boostsnippet("useForm Hook Example", "react") import { useForm } from '@inertiajs/react' export default function CreateUser() { const { data, setData, post, processing, errors } = useForm({ name: '', email: '', }) function submit(e) { e.preventDefault() post('/users') } return (
setData('name', e.target.value)} /> {errors.name &&
{errors.name}
} setData('email', e.target.value)} /> {errors.email &&
{errors.email}
}
) } @endboostsnippet ## Inertia v1 Limitations Inertia v1 does not support these v2 features: - `
` component - Deferred props - Prefetching - Polling - Infinite scrolling with `WhenVisible` - Merging props Do not use these features in v1 projects. ## Common Pitfalls - Using traditional `` links instead of Inertia's `` component (breaks SPA behavior) - Trying to use Inertia v2 features (deferred props, `` component, etc.) in v1 projects - Using `` without preventing default submission (use `e.preventDefault()`) - Not handling loading states during form submission