Frontend Development Standards
Tech Stack
Our frontend stack is built on modern technologies focusing on performance, maintainability, and developer experience.
Core Technologies
Framework & Libraries
Development Tools
- ESLint + Prettier
- Husky for Git hooks
- Jest + React Testing Library
- Storybook
- Webpack/Vite
Project Structure
Directory Organization
src/
├── components/
│ ├── common/
│ ├── features/
│ └── layouts/
├── hooks/
│ ├── api/
│ └── common/
├── pages/
├── store/
├── styles/
└── utils/
Component Architecture
Component Types
- Presentational Components
interface ButtonProps {
variant: 'primary' | 'secondary';
size: 'sm' | 'md' | 'lg';
children: React.ReactNode;
onClick?: () => void;
}
const Button: React.FC<ButtonProps> = ({
variant,
size,
children,
onClick
}) => {
return (
<button
className={`btn-${variant} btn-${size}`}
onClick={onClick}
>
{children}
</button>
);
};
- Container Components
const UserList: React.FC = () => {
const { data, isLoading } = useQuery('users', fetchUsers);
if (isLoading) return <Spinner />;
return (
<div>
{data.map(user => (
<UserCard key={user.id} user={user} />
))}
</div>
);
};
State Management
State Categories
- Local Component State: useState
- Server State: React Query
- Global App State: Redux Toolkit
- URL State: Next.js Router
Performance Optimization
Best Practices
Monitoring
- Lighthouse scores
- Core Web Vitals
- Bundle size analysis
- Performance monitoring
Testing Strategy
Unit Tests
describe('Button', () => {
it('renders with correct variant', () => {
render(<Button variant="primary">Click me</Button>);
expect(screen.getByRole('button')).toHaveClass('btn-primary');
});
});
Integration Tests
- Page load scenarios
- User flows
- API integration
- Error states
Accessibility (A11y)
Requirements
- WCAG 2.1 AA compliance
- Keyboard navigation
- Screen reader support
- Color contrast
Implementation
// Good example
const Button = ({ label, onClick }) => (
<button
onClick={onClick}
aria-label={label}
role="button"
>
{label}
</button>
);
CSS & Styling
Tailwind Best Practices
- Custom theme configuration
- Component-specific styles
- Responsive design
- Dark mode support
Design System Integration
See our Design System for detailed guidelines.
Security
Frontend Security Checklist
- XSS Prevention
- CSRF Protection
- Secure Authentication
- Input Validation
- Dependency Scanning
Build & Deployment
CI/CD Pipeline
- Lint & Type Check
- Unit Tests
- Build
- E2E Tests
- Deploy
Environment Configuration
// next.config.js
module.exports = {
env: {
API_URL: process.env.API_URL,
FEATURE_FLAGS: process.env.FEATURE_FLAGS,
},
};
Related Documents
Living Document
This document is regularly updated to reflect our evolving frontend practices and standards.