---
name: vigosan-frontend
description: React + TypeScript + Tailwind conventions from @vigosan's web and mobile apps — TanStack Query data layer, optimistic updates, Vitest + Testing Library. Use when building or changing React, Next.js, Vite or Expo UI in his projects.
license: MIT
metadata:
  generator: dna
  dna-version: "0.1-poc"
  dna-profile: https://dna.vicent.io/@vigosan
---

# Frontend like @vigosan

## Precedence

The repository's own conventions win. Use this skill for defaults and for what the repo doesn't decide yet. Use it together with `vigosan-methodology`.

## Stack defaults (observed)

- React with TypeScript (strict) and Tailwind CSS. Observed in 9 repositories.
- Framework is chosen per project: Next.js (7 repos) or Vite + TanStack Router (file-based routes). On a new project, ask.
- Mobile: Expo + Expo Router + Reanimated + Gesture Handler. Install native-aware packages with `npx expo install`, never with plain `npm add`.
- Validation at boundaries with Zod.

## Data layer

- Put raw HTTP calls in `services/` (typed `apiClient` functions), server state in `hooks/` (TanStack Query) and rendering in `routes/` or pages. Views never call the API client directly.
- No `useState` + `useEffect` fetch triads: use a query hook.
- Optimistic updates follow one sequence: `cancelQueries` → snapshot with `getQueryData` → `setQueryData` optimistic → on error restore the snapshot → on settled write the server response.
- Mutations invalidate the query keys they affect; keep query keys next to their hooks.
- Never edit generated files (route trees, generated clients). Change their source and regenerate.

## Components and styling

- Use semantic tokens from the Tailwind `@theme` (`bg-canvas`, `text-muted`…) instead of hex literals in components.
- Give every interactive element press feedback (`transition active:scale-[0.96]` or the project's equivalent).
- Set `sizes` on every `fill` image. Respect `prefers-reduced-motion`.
- Fonts: load through the framework's font system (`next/font`, Expo Font) rather than ad-hoc `<link>` tags when the framework offers one.

## Testing

- Vitest + Testing Library (+ `user-event`), jsdom. Polyfill what jsdom lacks (`localStorage` on Node ≥ 22, `matchMedia`, observers) in the test setup, not in each test.
- API routes: test with the framework's request helper (`app.request()` for Hono) and mock the database module before importing the app.
- Query elements by `data-testid` or role; never by class.
- E2E with Playwright where the flow crosses pages or devices.

## Before done

Run lint (Biome or ESLint + Prettier, whichever the repo uses), the type-check (`tsc --noEmit` / `tsc -b`) and the tests. `next build` type-checks more than Vitest does: run it before committing API or type changes.
