Progressive Enhancement Pattern
You'll learn how to build forms that work without JavaScript but enhance with client-side feedback when available.
Progressive enhancement is the practice of making your forms fully functional even when JavaScript fails to load or is disabled, then layering on interactive features when JavaScript is available. This pattern is particularly powerful with Server Components and Server Actions.
The Core Idea
Think of it like building a house: the foundation (HTML form) works on its own, but you add electricity (JavaScript) for conveniences like instant feedback and smoother interactions. If the power goes out, the house still functions.
With Server Actions, your form's action prop points to a server function. When submitted, the browser sends a POST request directly to the server, processes the action, and returns a response — no JavaScript required. This is how the web worked before JavaScript frameworks.
How It Works
Your form starts as pure HTML with a Server Action:
// Server Component
async function submitForm(formData: FormData) {
'use server'
const name = formData.get('name')
// Process and revalidate
revalidatePath('/dashboard')
}
export default function Form() {
return (
<form action={submitForm}>
<input name="name" required />
<button type="submit">Submit</button>
</form>
)
}
This works without JavaScript. Add a Client Component wrapping for enhancements:
'use client'
import { useFormStatus, useFormState } from 'react-dom'
function SubmitButton() {
const { pending } = useFormStatus()
return <button disabled={pending}>
{pending ? 'Submitting...' : 'Submit'}
</button>
}
When JavaScript loads, users get instant pending states. When it doesn't, the form still submits successfully.
Key Takeaway: Build forms that work server-side first with Server Actions, then enhance with useFormStatus and useFormState for better UX when JavaScript is available — the best of both worlds.