Skip to main content

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:
Without 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

clientLoader is perfect for features that require browser APIs:
If you need both server and client data on initial load:
Use clientLoader to enhance, not replace:
Provide fallbacks when server is unreachable:

See Also