Frontend Dev Guidelines (Senior Level)
This skill is at senior frontend developer knowledge level. Memorize patterns, recognize edge cases, reject anti-patterns.
1. Senior Developer Mindset
Think performance-first:
- Ask "is this causing unnecessary renders?" for every component
- Detect network waterfalls, use parallel fetch
- Monitor bundle size, lazy load heavy components
Internalize patterns:
React.FC<Props> + TypeScript always
useSWR with suspense: true is standard
SuspenseLoader NEVER early return with spinner
Reject anti-patterns:
- Convert barrel file imports to direct imports
- Replace sequential await with
Promise.all()
- Replace hardcoded colors with globals.css variables
2. Non-Negotiables (CRITICAL)
Component Patterns
// ✅ STANDARD PATTERN
import React from 'react';
import useSWR from 'swr';
import { SuspenseLoader } from '@/shared/components/SuspenseLoader';
const HeavyComponent = React.lazy(() => import('./HeavyComponent'));
interface MyComponentProps {
id: string;
className?: string;
}
export const MyComponent: React.FC<MyComponentProps> = ({ id, className }) => {
const { data } = useSWR(`key-${id}`, () => api.get(id), { suspense: true });
return <div className={cn("base-class", className)}>{data?.title}</div>;
};
// Usage - with Suspense boundary
<SuspenseLoader>
<MyComponent id="123" />
</SuspenseLoader>
Performance Rules (Top 15)
| Priority |
Rule |
Description |
| CRITICAL |
Promise.all() |
Parallelize independent async operations |
| CRITICAL |
Direct imports |
Avoid barrel files, import directly |
| CRITICAL |
next/dynamic |
Dynamic import heavy components |
| CRITICAL |
Suspense boundaries |
Stream content, prevent waterfalls |
| HIGH |
Defer await |
Move await to the branch where it's used |
| HIGH |
Minimize RSC serialization |
Send less data to client |
| HIGH |
React.cache() |
Per-request deduplication |
| MEDIUM |
SWR deduplication |
Auto request deduplication |
| MEDIUM |
Functional setState |
setCount(c => c + 1) stable callback |
| MEDIUM |
Lazy state init |
useState(() => expensiveCalc()) |
| MEDIUM |
startTransition |
For non-urgent updates |
| MEDIUM |
content-visibility |
CSS optimize for long lists |
| LOW |
Index maps |
Use Map for repeated lookups |
| LOW |
toSorted() |
For immutable sort |
| LOW |
Set/Map lookups |
O(1) lookup instead of array |
Accessibility Rules (Top 10)
| Rule |
Description |
aria-label on icon buttons |
ALWAYS add aria-label to icon-only buttons |
button vs a/Link |
Action = button, Navigation = a/Link |
alt on images |
Add alt to every img (decorative: alt="") |
| Keyboard handlers |
Add keyboard support to interactive elements |
| Heading hierarchy |
Maintain h1 → h2 → h3 order |
autocomplete on inputs |
Add autocomplete to form inputs |
| Inline errors |
Show errors next to field |
| Submit button enabled |
Don't disable submit, show loading spinner |
| Virtualize long lists |
Virtualize lists with 50+ items |
prefers-reduced-motion |
Check motion preference in animations |
3. Browser Compatibility (SAFARI CRITICAL)
Check Safari on every code change! Safari is the most problematic browser.
| Issue |
Safari Fix |
Reference |
new Date('2024-01-15 10:30:00') |
ISO 8601: '2024-01-15T10:30:00' |
browser-compatibility.md |
height: 100vh |
height: 100dvh or -webkit-fill-available |
browser-compatibility.md |
backdrop-filter |
Add -webkit-backdrop-filter prefix |
browser-compatibility.md |
| Video autoplay |
playsInline + muted attributes |
browser-compatibility.md |
| Input zoom (iOS) |
font-size: 16px minimum |
browser-compatibility.md |
| Touch events |
{ passive: true } listener |
browser-compatibility.md |
| Clipboard API |
Fallback textarea method |
browser-compatibility.md |
Test Checklist (Every PR):
4. Anti-Patterns (NEVER DO)
| Anti-Pattern |
Correct Pattern |
Reference |
if (isLoading) return <Spinner /> |
Wrap with <SuspenseLoader> |
core-patterns.md |
| Sequential await |
Use Promise.all() |
performance-guide.md |
| Barrel file import |
Use direct import |
performance-guide.md |
Hardcoded color bg-[#fe4601] |
CSS variable bg-orange-1 |
styling-routing.md |
<div onClick> |
<button onClick> |
accessibility-guide.md |
| Icon button without label |
Add aria-label |
accessibility-guide.md |
| Server data in useState |
Use useSWR |
core-patterns.md |
next/router import |
Use next/navigation |
styling-routing.md |
dangerouslySetInnerHTML |
DOMPurify sanitization |
security-error-handling.md |
any type |
unknown + type guard |
advanced-typescript.md |
Type assertion as User |
Runtime validation (Zod) |
advanced-typescript.md |
5. Decision Trees
useState vs Zustand vs SWR
What's the data source?
├─ Server/API → SWR (suspense: true)
├─ Form input → useState (local)
├─ UI state (modal, sidebar) → useState (local)
└─ Shared across components?
├─ Server data → SWR (auto-shares)
└─ Client state → Zustand (ONLY)
Server vs Client Component
What does the component do?
├─ Static content → Server Component
├─ Data fetch (no interaction) → Server Component
├─ Needs useState/useEffect → Client Component
├─ Has onClick/onChange handler → Client Component
├─ Uses Browser API → Client Component
└─ Third-party client library → Client Component
useMemo vs React.memo vs useCallback
What are you optimizing?
├─ Expensive calculation → useMemo
├─ Object/array reference stability → useMemo
├─ Function reference stability → useCallback
├─ Child component re-render → React.memo (on child)
└─ Event handler in dependency → useCallback
Lazy Loading Decision
Is the component heavy?
├─ DataGrid/Table → lazy load
├─ Chart/Graph → lazy load
├─ Rich text editor → lazy load
├─ Video player → lazy load
├─ Small utility component → don't lazy load
└─ Above-the-fold critical → don't lazy load
6. Quick Reference
For detailed info: styling-routing.md
| Topic |
Source |
Import aliases (@/, @/shared, @/features) |
styling-routing.md |
| Feature directory structure |
styling-routing.md |
Route groups ((dashboard), (main), etc.) |
styling-routing.md |
| Color palettes (globals.css) |
styling-routing.md |
7. Resources (Detailed Info)
| Topic |
Resource |
| Component, data fetching, React 19 hooks, state |
core-patterns.md |
| All performance rules (45 rules) |
performance-guide.md |
| Accessibility patterns (WCAG 2.1) |
accessibility-guide.md |
| Tailwind, routing, file organization |
styling-routing.md |
| Testing patterns, complete examples |
testing-examples.md |
| Safari/Chrome/Firefox compatibility, Senior FE skills |
browser-compatibility.md |
| XSS/CSRF prevention, error boundaries, resilience |
security-error-handling.md |
| Generics, type guards, utility types, inference |
advanced-typescript.md |
Quick Template
import React from 'react';
import useSWR from 'swr';
import { Card, CardHeader, CardTitle, CardContent } from '@/shared/components/ui/card';
import { cn } from '@/shared/utils/cn';
import { featureApi } from '../api/featureApi';
interface FeatureCardProps {
id: string;
className?: string;
}
export const FeatureCard: React.FC<FeatureCardProps> = ({ id, className }) => {
const { data } = useSWR(`feature-${id}`, () => featureApi.get(id), { suspense: true });
return (
<Card className={cn("w-full", className)}>
<CardHeader>
<CardTitle>{data?.title}</CardTitle>
</CardHeader>
<CardContent>
<p className="text-muted-foreground">{data?.description}</p>
</CardContent>
</Card>
);
};
Related Skills
- react-best-practices: Full 45 performance rules (Vercel Engineering)
- web-design-guidelines: Full UI/UX/a11y rules (Vercel Labs)
- error-tracking: Sentry integration
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: frontend-dev-guidelines-83description: Frontend development guidelines for React/TypeScript applications. Modern patterns including Suspense, lazy loading, useSWR, file organization with features directory, shadcn/ui components, Tailwind CSS styling, Next.js App Router, performance optimization, and TypeScript best practices. Use when creating components, pages, features, fetching data, styling, routing, or working with frontend code. Use when this capability is needed.4---56# Frontend Dev Guidelines (Senior Level)78> **This skill is at senior frontend developer knowledge level.** Memorize patterns, recognize edge cases, reject anti-patterns.910---1112## 1. Senior Developer Mindset1314**Think performance-first:**15- Ask "is this causing unnecessary renders?" for every component16- Detect network waterfalls, use parallel fetch17- Monitor bundle size, lazy load heavy components1819**Internalize patterns:**20- `React.FC<Props>` + TypeScript always21- `useSWR` with `suspense: true` is standard22- `SuspenseLoader` NEVER early return with spinner2324**Reject anti-patterns:**25- Convert barrel file imports to direct imports26- Replace sequential await with `Promise.all()`27- Replace hardcoded colors with globals.css variables2829---3031## 2. Non-Negotiables (CRITICAL)3233### Component Patterns3435```typescript36// ✅ STANDARD PATTERN37import React from 'react';38import useSWR from 'swr';39import { SuspenseLoader } from '@/shared/components/SuspenseLoader';4041const HeavyComponent = React.lazy(() => import('./HeavyComponent'));4243interface MyComponentProps {44 id: string;45 className?: string;46}4748export const MyComponent: React.FC<MyComponentProps> = ({ id, className }) => {49 const { data } = useSWR(`key-${id}`, () => api.get(id), { suspense: true });50 return <div className={cn("base-class", className)}>{data?.title}</div>;51};5253// Usage - with Suspense boundary54<SuspenseLoader>55 <MyComponent id="123" />56</SuspenseLoader>57```5859### Performance Rules (Top 15)6061| Priority | Rule | Description |62|----------|------|-------------|63| CRITICAL | `Promise.all()` | Parallelize independent async operations |64| CRITICAL | Direct imports | Avoid barrel files, import directly |65| CRITICAL | `next/dynamic` | Dynamic import heavy components |66| CRITICAL | Suspense boundaries | Stream content, prevent waterfalls |67| HIGH | Defer await | Move await to the branch where it's used |68| HIGH | Minimize RSC serialization | Send less data to client |69| HIGH | `React.cache()` | Per-request deduplication |70| MEDIUM | SWR deduplication | Auto request deduplication |71| MEDIUM | Functional setState | `setCount(c => c + 1)` stable callback |72| MEDIUM | Lazy state init | `useState(() => expensiveCalc())` |73| MEDIUM | `startTransition` | For non-urgent updates |74| MEDIUM | `content-visibility` | CSS optimize for long lists |75| LOW | Index maps | Use Map for repeated lookups |76| LOW | `toSorted()` | For immutable sort |77| LOW | Set/Map lookups | O(1) lookup instead of array |7879### Accessibility Rules (Top 10)8081| Rule | Description |82|------|-------------|83| `aria-label` on icon buttons | ALWAYS add aria-label to icon-only buttons |84| `button` vs `a/Link` | Action = button, Navigation = a/Link |85| `alt` on images | Add alt to every img (decorative: `alt=""`) |86| Keyboard handlers | Add keyboard support to interactive elements |87| Heading hierarchy | Maintain h1 → h2 → h3 order |88| `autocomplete` on inputs | Add autocomplete to form inputs |89| Inline errors | Show errors next to field |90| Submit button enabled | Don't disable submit, show loading spinner |91| Virtualize long lists | Virtualize lists with 50+ items |92| `prefers-reduced-motion` | Check motion preference in animations |9394---9596## 3. Browser Compatibility (SAFARI CRITICAL)9798> **Check Safari on every code change!** Safari is the most problematic browser.99100| Issue | Safari Fix | Reference |101|-------|------------|-----------|102| `new Date('2024-01-15 10:30:00')` | ISO 8601: `'2024-01-15T10:30:00'` | browser-compatibility.md |103| `height: 100vh` | `height: 100dvh` or `-webkit-fill-available` | browser-compatibility.md |104| `backdrop-filter` | Add `-webkit-backdrop-filter` prefix | browser-compatibility.md |105| Video autoplay | `playsInline` + `muted` attributes | browser-compatibility.md |106| Input zoom (iOS) | `font-size: 16px` minimum | browser-compatibility.md |107| Touch events | `{ passive: true }` listener | browser-compatibility.md |108| Clipboard API | Fallback textarea method | browser-compatibility.md |109110### Test Checklist (Every PR):111- [ ] Chrome (latest)112- [ ] Safari (macOS)113- [ ] Safari (iOS) - Real device or simulator114- [ ] Firefox (latest)115116---117118## 4. Anti-Patterns (NEVER DO)119120| Anti-Pattern | Correct Pattern | Reference |121|--------------|-----------------|-----------|122| `if (isLoading) return <Spinner />` | Wrap with `<SuspenseLoader>` | core-patterns.md |123| Sequential await | Use `Promise.all()` | performance-guide.md |124| Barrel file import | Use direct import | performance-guide.md |125| Hardcoded color `bg-[#fe4601]` | CSS variable `bg-orange-1` | styling-routing.md |126| `<div onClick>` | `<button onClick>` | accessibility-guide.md |127| Icon button without label | Add `aria-label` | accessibility-guide.md |128| Server data in useState | Use `useSWR` | core-patterns.md |129| `next/router` import | Use `next/navigation` | styling-routing.md |130| `dangerouslySetInnerHTML` | DOMPurify sanitization | security-error-handling.md |131| `any` type | `unknown` + type guard | advanced-typescript.md |132| Type assertion `as User` | Runtime validation (Zod) | advanced-typescript.md |133134---135136## 5. Decision Trees137138### useState vs Zustand vs SWR139140```141What's the data source?142├─ Server/API → SWR (suspense: true)143├─ Form input → useState (local)144├─ UI state (modal, sidebar) → useState (local)145└─ Shared across components?146 ├─ Server data → SWR (auto-shares)147 └─ Client state → Zustand (ONLY)148```149150### Server vs Client Component151152```153What does the component do?154├─ Static content → Server Component155├─ Data fetch (no interaction) → Server Component156├─ Needs useState/useEffect → Client Component157├─ Has onClick/onChange handler → Client Component158├─ Uses Browser API → Client Component159└─ Third-party client library → Client Component160```161162### useMemo vs React.memo vs useCallback163164```165What are you optimizing?166├─ Expensive calculation → useMemo167├─ Object/array reference stability → useMemo168├─ Function reference stability → useCallback169├─ Child component re-render → React.memo (on child)170└─ Event handler in dependency → useCallback171```172173### Lazy Loading Decision174175```176Is the component heavy?177├─ DataGrid/Table → lazy load178├─ Chart/Graph → lazy load179├─ Rich text editor → lazy load180├─ Video player → lazy load181├─ Small utility component → don't lazy load182└─ Above-the-fold critical → don't lazy load183```184185---186187## 6. Quick Reference188189> **For detailed info:** [styling-routing.md](resources/styling-routing.md)190191| Topic | Source |192|-------|--------|193| Import aliases (`@/`, `@/shared`, `@/features`) | styling-routing.md |194| Feature directory structure | styling-routing.md |195| Route groups (`(dashboard)`, `(main)`, etc.) | styling-routing.md |196| Color palettes (globals.css) | styling-routing.md |197198---199200## 7. Resources (Detailed Info)201202| Topic | Resource |203|-------|----------|204| Component, data fetching, React 19 hooks, state | [core-patterns.md](resources/core-patterns.md) |205| All performance rules (45 rules) | [performance-guide.md](resources/performance-guide.md) |206| Accessibility patterns (WCAG 2.1) | [accessibility-guide.md](resources/accessibility-guide.md) |207| Tailwind, routing, file organization | [styling-routing.md](resources/styling-routing.md) |208| Testing patterns, complete examples | [testing-examples.md](resources/testing-examples.md) |209| Safari/Chrome/Firefox compatibility, Senior FE skills | [browser-compatibility.md](resources/browser-compatibility.md) |210| **XSS/CSRF prevention, error boundaries, resilience** | [security-error-handling.md](resources/security-error-handling.md) |211| **Generics, type guards, utility types, inference** | [advanced-typescript.md](resources/advanced-typescript.md) |212213---214215## Quick Template216217```typescript218import React from 'react';219import useSWR from 'swr';220import { Card, CardHeader, CardTitle, CardContent } from '@/shared/components/ui/card';221import { cn } from '@/shared/utils/cn';222import { featureApi } from '../api/featureApi';223224interface FeatureCardProps {225 id: string;226 className?: string;227}228229export const FeatureCard: React.FC<FeatureCardProps> = ({ id, className }) => {230 const { data } = useSWR(`feature-${id}`, () => featureApi.get(id), { suspense: true });231232 return (233 <Card className={cn("w-full", className)}>234 <CardHeader>235 <CardTitle>{data?.title}</CardTitle>236 </CardHeader>237 <CardContent>238 <p className="text-muted-foreground">{data?.description}</p>239 </CardContent>240 </Card>241 );242};243```244245---246247## Related Skills248249- **react-best-practices**: Full 45 performance rules (Vercel Engineering)250- **web-design-guidelines**: Full UI/UX/a11y rules (Vercel Labs)251- **error-tracking**: Sentry integration252253---254> Converted and distributed by [TomeVault](https://tomevault.io/claim/rylaa) — claim your Tome and manage your conversions.255<!-- tomevault:4.0:skill_md:2026-04-13 -->