After redirect back to a form page, the old form values are still displayed on Inertia.js on Laravel 8
Stefan Bogdanescu
Founder & Senior Architect · 2026-06-29
Solving the Inertia State Persistence Puzzle: Why Old Form Values Remain After Redirects in Laravel
As developers working with modern full-stack frameworks like Laravel and Inertia.js, we often encounter subtle but frustrating state management issues. One common sticking point involves navigating between pages that contain form data, especially when performing destructive actions like deletions. You’ve hit a classic scenario: attempting to clear the state after an Inertia redirect fails to fully clean up the previous page's display.
This post dives deep into why this happens in Inertia applications using Laravel and Vue, analyzes your attempted solutions, and provides the definitive, robust way to handle form state persistence correctly.
The Mystery of Persistent Form Data in Inertia
The scenario you described—where deleting a record redirects back to a previous form page, but the old values are still visible—is a common pitfall related to how Inertia manages component state versus how client-side libraries like Vue's useForm manage data.
When you perform an action via Inertia.post(), Inertia handles the HTTP request and the subsequent response. The behavior of what is preserved or reset often depends on the specific configuration flags used, and crucially, where the state lives (server-side vs. client-side).
The core conflict here is between:
- Inertia's
preserveState: Controls whether Inertia should keep the component state from the previous request in the new page. - Vue's
useFormState: Controls the local, mutable data held by your component instance.
Your attempts using preserveState: false and form.reset() failed because they addressed different layers of persistence. We need a strategy that ensures both the server response and the client-side form object are synchronized correctly upon deletion.
Analyzing Your Attempts and Identifying the Flaw
Let's review why your initial methods didn't resolve the issue:
Inertia.post(..., { preserveState: false }): This flag primarily affects how Inertia handles the component state transfer during the navigation. While useful for preventing old page rendering, it doesn't necessarily clear data that might have been initialized or side-effected by a previous successful submission on the receiving page.form.post(..., { preserveState: false }): This is an attempt to control the form state directly usinguseForm, but as you found, it often doesn't override Inertia’s underlying mechanism for rendering data.onSuccess: () => form.reset(): Resetting the local form object only clears the client-side view of the data; it does not affect what the server sends back or how Inertia manages component state across redirects.
The problem is that when you delete a record, the subsequent request might still be pulling stale data from the session or previous page context before a full refresh occurs, especially if the form object initialization isn't fully decoupled from the navigation flow.
The Robust Solution: Server-Side Control and Full Refresh
The most reliable solution involves ensuring that the state management is handled holistically by the server logic, which adheres to best practices in application design, much like how you structure controllers when building robust APIs with Laravel.
Instead of relying solely on client-side flags, we should leverage the backend response to dictate the next step completely.
Recommended Approach: Clearing State on the Server
The key is to ensure that the data returned after a successful deletion operation does not contain any remnants from the previous form submission context. This is achieved by ensuring your Laravel controller explicitly returns a clean view or redirect, rather than relying solely on Inertia’s state preservation flags for cleanup.
In your Inertia call, focus on a complete page refresh, which often involves making sure the delete action itself handles the data clearing:
const deleteDraft = () => {
if (confirm("Delete the draft?")) {
// Use a standard POST/DELETE request that expects a fresh response.
Inertia.post(props.deleteDraftUrl, null, {
preserveState: false, // Ensure no state is carried over from previous component context
onSuccess: () => {
// After a successful deletion, we explicitly tell Inertia to navigate away
// and refresh the view based on the new request, effectively clearing old form data.
console.log('Deletion successful!');
},
});
}
};
While form.reset() is good practice for local form state management within that component, when dealing with cross-page navigation triggered by a destructive action, letting Inertia handle the full request/response cycle with minimal client-side manipulation often yields the cleanest result. Always remember that solid backend logic, as championed by Laravel, provides the foundation for flawless frontend interactions.
Conclusion
Dealing with state persistence in SPA frameworks built on top of Laravel requires understanding the interaction between server responses and client-side state management tools. The issue you faced is a classic example of where client-side flags like preserveState are insufficient when dealing with complex redirects involving form data.
By focusing your efforts on ensuring that the server response for the deletion action is completely clean, and by using Inertia's features to enforce a full state refresh (preserveState: false), you can successfully eliminate stale form values. Always prioritize clean data flow from the backend—a principle that aligns perfectly with Laravel’s philosophy of building robust applications.