Nakodo is a Next.js app over 25 Postgres tables with 76 public pages in front of the login. Its src/hooks directory holds this:
$ wc -l src/hooks/ * 18 src/hooks/use-action.ts 50 src/hooks/use-confirm.tsx 68 total
Enter fullscreen mode
Exit fullscreen mode
There are five other functions in the codebase whose names begin with use , and all five sit in the file of the feature that needs them: usePlanChange and useUpgrade next to the plan switcher, useShares next to the campaign shares editor, useSaveFirst next to the context it reads, useIlloId next to the illustrations. The two in src/hooks are the two that are used by unrelated screens, which is the whole rule for what goes there.
The confirm hook
export type Ask = { title : string ; text : string ; action : string ; // the confirm button cancel ?: string ; destructive ?: boolean ; run : () => void ; };
// One confirmation dialog per component, kept filled while it animates out.…