State Management · Middle · Question 43 of 75
How do you set a default fetcher and options for all SWR hooks?
- ✓Correct answer: Wrap the app in
<SWRConfig value={{ fetcher, ... }}> - 2Call
useSWR.defaults = { fetcher }at startup - 3Pass the fetcher to every hook - global options aren't supported
Explanation
SWRConfig sets global options (fetcher, revalidateOnFocus, error handlers) and can be nested to override them for a subtree. It can also provide initial fallback data from SSR.