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

The Custom Hook Naming Convention: useX

Prefixing with 'use' signals to linters and developers that a function obeys hook rules.

The Custom Hook Naming Convention: useX

What you'll learn: Why every custom hook must start with "use" and how this simple naming convention enables critical tooling and code clarity.

The Convention

When you create a custom hook in React, you must name it starting with the word "use" followed by a descriptive name in camelCase. For example: useToggle, useLocalStorage, useDebounce.

This isn't just a style preference—it's a strict requirement that React's ecosystem depends on.

Why "use" Matters

The "use" prefix serves as a signal to two important audiences:

1. Linting Tools

React's ESLint plugin (eslint-plugin-react-hooks) automatically recognizes any function starting with "use" as a hook. This allows the linter to:

  • Enforce the Rules of Hooks (top-level only, consistent order)
  • Validate dependency arrays in useEffect, useMemo, and useCallback
  • Catch violations that would cause runtime bugs

Without the "use" prefix, the linter treats your function as regular JavaScript and won't check for hook rule violations.

2. Human Developers

When you or a teammate see useFormInput in code, you immediately know:

  • This function follows the Rules of Hooks
  • It can only be called from React components or other custom hooks
  • It likely manages stateful logic or side effects

The naming convention creates instant recognition, like seeing handle at the start of an event handler name.

The Analogy

Think of "use" like a uniform. Just as a chef's hat signals "this person works with food and follows kitchen safety rules," the "use" prefix signals "this function works with React state and follows hook rules."

Key Takeaway: Always prefix custom hooks with "use"—it's not optional. This naming convention activates essential linting and communicates hook behavior to everyone reading your code.