React Component Generator
Process
- Confirm whether the component is presentational (no data fetching) or container (fetches/owns data). Presentational components are strongly preferred — push data fetching to the Server Component parent and pass props down.
- Create the folder structure:
src/components/<ComponentName>/ <ComponentName>.tsx <ComponentName>.test.tsx index.ts - Use component-template.tsx as the starting point.
- Define
<ComponentName>Propsas an exported interface so it can be reused/extended by consumers. - Style exclusively with Tailwind utility classes; use the
cn()helper fromsrc/lib/utils.tsfor conditional classes. - Add a basic render + interaction test using React Testing Library — see component-test-template.tsx.
- Export the component from the folder's
index.tsso consumers importfrom '@/components/ComponentName', not deep paths.
Decision: client or server?
Default: no "use client" directive. Add it only if the component uses:
useState,useEffect,useReducer, or any other hook with browser/runtime behavior- Event handlers (
onClick,onChange, etc.) - Browser-only APIs (
window,localStorage)
Checklist
- Props interface exported
- No
"use client"unless actually needed - Tailwind only, no inline styles
- Accessible (labels, roles, keyboard support)
- Test file created
- Exported via
index.ts