HeadlinesBriefing favicon HeadlinesBriefing.com

JavaScript Hook Naming Crisis: A Call for Sanity

DEV Community •
×

JavaScript developers face a naming crisis where hooks like useQuery, useClient, and useAuth are exported by dozens of libraries—Apollo, React Query, Supabase, Firebase, and more—with completely different APIs. This creates import conflicts, auto-import bugs, and refactoring nightmares, as the same name performs GraphQL queries, REST calls, database operations, and searches.

The problem extends beyond React to Vue, Solid, and other frameworks, with libraries like Zustand, Jotai, and Valtio all exporting useStore. The ecosystem's lack of naming standards forces developers to use aliases like `useGraphQLQuery` and `useRESTQuery`, increasing cognitive load and error rates. This isn't just inconvenient; it's a systemic developer experience failure.

A proposed JavaScript Hook Naming Convention (JHNC) suggests prefixing exports with library identity, like `useTanStackQuery` instead of generic `useQuery`. The solution requires library authors to adopt phased migrations, adding prefixed exports while deprecating old names. Without action, the problem worsens as new libraries repeat the same pattern, harming onboarding and productivity across the stack.