Skip to content

TypeScript · performance

no-client-side-data-fetching

eslint:no-client-side-data-fetching

Disallow direct data fetching inside `useEffect` or `useLayoutEffect`.

Default
error
Fix
none
Languages
typescript

Why

Effect-driven reads begin after rendering and can create request waterfalls, duplicate fetches, and loading-state layout shifts.

Fix

Fetch in a React Server Component or Server Action, or use a client cache such as SWR or React Query.

Before / after

Executed by this rule’s unit tests.

Before

An effect starts a data request

src/users.tsx · focus
useEffect(() => { fetch('/api/users'); }, []);

After

An effect performs no data request

src/users.tsx · focus
import { useEffect } from 'react'; useEffect(() => { console.log('mounted'); }, []);

Limits

  • The rule recognizes common fetch clients syntactically and exempts analytics endpoints and non-GET `fetch` calls.

Message IDs

noClientFetch