a black dog running with a stick in its mouth

How to use a Remix form with an action without following its URL

I’m relatively new to remix.run and try to follow the best practices (e.g. use forms for everything).

Today I wanted to have a form for an action that does not update the URL. If I kept it with the default form, refreshing the page would lead to an error because I didn’t want to add a loader to the action route.

It turns out, there is a useFetcher hook, that also provides a <fetcher.Form> component, which works just like a regular form but does not redirect the user to the form action URL.

Neat!


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.