---
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."
license: MIT
metadata:
author: laravel
---
@php
/** @var \Laravel\Boost\Install\GuidelineAssist $assist */
@endphp
# Inertia React Development
## 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 `{{ $assist->inertia()->pagesDirectory() }}` directory.
### Page Component Structure
@boostsnippet("Basic React Page Component", "react")
export default function UsersIndex({ users }) {
return (
Users
{users.map(user => - {user.name}
)}
)
}
@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 (
)
}
@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 (
)
}
@endboostsnippet
## Inertia v1 Limitations
Inertia v1 does not support these v2 features:
- `