clientLoader
A client-side data loading function that runs in the browser, allowing you to fetch data from APIs, access browser storage, or augment server loader data.Signature
ClientLoaderFunctionArgs
required
Arguments passed to the clientLoader function
Data | Promise<Data>
Data to be used by the route component (accessible via
useLoaderData())Basic Example
Calling Server Loader
Skipping Server Loader
Hydrate Option
Control whether clientLoader runs on initial page load:hydrate = true, clientLoader only runs on client-side navigation:
HydrateFallback
Show a loading state during hydration:Client-Side Caching
Accessing Browser APIs
Combining Server and Client Data
Progressive Enhancement
Error Handling
Conditional Server Calls
Best Practices
Use for client-only features
Use for client-only features
clientLoader is perfect for features that require browser APIs:
Set hydrate = true when augmenting server data
Set hydrate = true when augmenting server data
If you need both server and client data on initial load:
Don't duplicate server logic unnecessarily
Don't duplicate server logic unnecessarily
Use clientLoader to enhance, not replace:
Handle offline scenarios
Handle offline scenarios
Provide fallbacks when server is unreachable:
See Also
- loader - Server-side data loading
- clientAction - Client-side mutations
- useLoaderData - Access loader data