Skip to main content

useFetcher

Useful for creating complex, dynamic user interfaces that require multiple, concurrent data interactions without causing a navigation.
This hook only works in Data and Framework modes.
Fetchers track their own, independent state and can be used to load data, submit forms, and generally interact with action and loader functions without navigating.

Signature

Parameters

string
A unique key to identify the fetcher. If you want to access the same fetcher from elsewhere in your app, provide a key. By default, useFetcher generates a unique fetcher scoped to that component.

Returns

FetcherWithComponents<T>
An object with the following properties:

Usage

Basic usage

Load data

Submit data imperatively

Submit FormData

Submit JSON

Reset fetcher

Shared fetcher with key

Common Patterns

Optimistic UI

Inline editing

Mark as read

Autocomplete

Add to cart

Type Safety

With TypeScript

With loader/action types

  • useFetchers - Access all in-flight fetchers
  • useSubmit - Submit forms imperatively with navigation
  • Form - Form component with navigation
  • action - Define route action
  • loader - Define route loader