5 custom hooks I copy to every React project. Not from a library. Not from a tutorial. From production. Here's my starter kit: 𝟏. 𝘂𝘀𝗲𝗗𝗲𝗯𝗼𝘂𝗻𝗰𝗲() Search inputs, resize handlers, API calls — without re-render storms. I've seen apps making 40+ API calls per keystroke. This hook kills that. 𝟐. 𝘂𝘀𝗲𝗣𝗿𝗲𝘃𝗶𝗼𝘂𝘀() Tracks the previous value of any state or prop. Essential for debugging re-renders and building "changed from X to Y" logic. 𝟑. 𝘂𝘀𝗲𝗟𝗼𝗰𝗮𝗹𝗦𝘁𝗼𝗿𝗮𝗴𝗲() useState, but persistent. Survives page refresh. The catch most people miss: SSR safety. window doesn't exist on the server. 𝟒. 𝘂𝘀𝗲𝗠𝗲𝗱𝗶𝗮𝗤𝘂𝗲𝗿𝘆() Responsive logic in JS without CSS hacks. Show/hide components, change layouts, adjust behavior — all reactive, all clean. 𝟓. 𝘂𝘀𝗲𝗔𝗯𝗼𝗿𝘁𝗖𝗼𝗻𝘁𝗿𝗼𝗹𝗹𝗲𝗿() Auto-cancels fetch requests on component unmount. Nobody writes this hook. Until production breaks with a race condition at 2 AM. The pattern I've noticed after 8+ years: Senior engineers don't write more code. They carry better defaults. These 5 hooks are ~150 lines total. They prevent thousands of lines of bug fixes. What's in your starter kit? #React #JavaScript #TypeScript #CustomHooks #WebDevelopment #FrontendDevelopment #ReactHooks #CleanCode #SoftwareArchitecture #CodingTips
React has the full kit for production, Good Tech Really Good Morning Alex
very nice, i would just add that useLocalStorage need to be used more carefully in the EU / CAN as it is under the same law as cookie are for privacy, but really usefull idea.
I'd add useThrottle()
Jude Oluwadunsi Exactly right! That mental model keeps things simple. I'd only add: once your project has workspaces or a monorepo structure, pnpm becomes almost mandatory — its strict hoisting prevents phantom dependencies that npm silently allows. Saved me from multiple production issues.