When you use <Form method="post"> in Remix, as opposed to using the native HTML <form method="post">, Remix does not adhere to the default browser behavior for resubmitting forms during navigation events like clicking back, forward, or refreshing.
In a standard browser environment, form submissions are navigation events. This means that when a user clicks the back button, the browser will typically resubmit the form. For example:
/buy/checkout/order/123The browser history stack would look like this:
GET /buy > POST /checkout > *GET /order/123
If the user clicks the back button, the history becomes:
GET /buy - *POST /checkout < GET /order/123
In this situation, the browser resubmits the form data, which could lead to issues such as charging a credit card twice.
actionsA common practice to avoid this issue is to issue a redirect after the POST request. This removes the POST action from the browser's history. The history stack would then look like this:
GET /buy > POST /checkout, Redirect > GET /order/123
With this approach, clicking the back button would not resubmit the form:
GET /buy - *GET /order/123
While accidental resubmissions generally don't happen in Remix, there are specific scenarios where they might.
<form> instead of <Form><Form reloadDocument><Scripts/>It's advisable to implement a redirect from the action to avoid unintended resubmissions.
Guides
API