Instruction file imported from FaizAhemad962/gadgify (
.github/instructions/frontend.instructions.md). Copyright stays with the author.
Frontend Development Rules
Component Structure
- Use functional components with TypeScript interfaces for props
- Colocate types at top of file or in a shared
types/folder - Export components as default, hooks as named exports
Data Fetching
- ALL server data via React Query (
useQuery,useMutation) - Never use
useState+useEffectfor API data - API functions go in
frontend/src/api/— hooks wrap them infrontend/src/hooks/ - Invalidate related queries after mutations
Forms
- React Hook Form +
@hookform/resolvers/zodfor all forms - Define Zod schemas next to form components or in a
schemas/file - Show MUI
helperTextfor field errors
i18n
const { t } = useTranslation();in every component with user-facing text- Keys in
frontend/src/i18n/locales/{en,mr,hi}.json - Never hardcode strings shown to users
Styling
- Use MUI
sxprop orstyled()— no raw CSS files - Use theme tokens (
theme.palette,theme.spacing) — no magic numbers - Responsive: use MUI breakpoints (
{ xs: ..., md: ... })
Error Handling
- React Query
onErrorfor API errors - Show
SnackbarorAlertfor user-facing errors - Never
console.login production code — useconsole.erroronly for unexpected failures