Course contentsShow
← React
Lesson 983 of 2,39625. Custom HooksFree lesson

The useX Naming Pattern

Learn the standard naming convention: 'use' + descriptive noun or verb phrase (e.g., useCounter, useFetch, useLocalStorage).

The useX Naming Pattern

You'll learn the standard naming convention that makes custom hooks instantly recognizable and discoverable in React codebases.

Why Naming Matters

In the previous lesson, you learned that custom hooks must start with "use" for React's rules to apply. But there's more to it than just starting with those three letters—the rest of the name* matters too for code clarity.

The Pattern: use + Descriptive Name

The convention is simple: use followed by a descriptive noun or verb phrase that clearly states what the hook does or provides.

Good examples:

  • useCounter — manages a counter value
  • useFetch — handles data fetching
  • useLocalStorage — syncs state with localStorage
  • useToggle — manages boolean toggle state
  • useDebounce — debounces a value
  • useWindowSize — tracks window dimensions

Poor examples:

  • handleCounter — doesn't start with "use"
  • use — not descriptive
  • useIt — vague, tells you nothing
  • useDataFromAPI — too verbose, useFetch is clearer

Think Like a Developer

When you see useCart in someone's code, you immediately know: this is a hook, it follows React's rules, and it probably manages shopping cart logic. The name becomes documentation.

Compare this to a function called getCart() or cartHelper()—you'd have no idea whether those are regular functions, whether they can use hooks inside, or when to call them.

Key Takeaway: Name your custom hooks with use + a clear, descriptive word or phrase that immediately communicates its purpose. This convention makes your hooks discoverable, maintainable, and signals to other developers (and React's linter) that hook rules apply inside.