takeoff-ui-vite-frontend-builder
React + TanStack + TakeOff UI Enterprise Builder
Overview
This skill guides you through building production-ready, secure React frontends with:
- Vite - Modern build tool for fast development
- TanStack Query - Powerful data synchronization and caching
- TanStack Router - Type-safe file-based routing
- TakeOff UI - Enterprise component library with Tailwind integration
- Tailwind CSS - Utility-first styling (NO custom CSS files)
- TypeScript - Type safety throughout
- Centralized Auth - OAuth 2.0 or JWT-based authentication
- Dynamic UI Generation - Forms and tables from backend schemas
- Clean Architecture - Strict separation of concerns
When to Use This Skill
- Starting a new React frontend project
- Building API-driven applications with dynamic UIs
- Implementing secure authentication (OAuth/JWT)
- Creating enterprise applications with TakeOff UI
- Migrating React apps to scalable architecture
- Setting up backend-frontend schema contracts
Core Principles
- Tailwind-Only Styling - Never create CSS files or custom classes
- API-First Design - UI components driven by backend schemas
- Separation of Concerns - Services ≠ Hooks ≠ Components ≠ Pages
- Component Approval - Always request approval before using new TakeOff UI components
- Type Safety - TypeScript everywhere, no
anytypes - Security First - Centralized auth, token management, API interceptors
Initial Setup Workflow
Step 1: TakeOff UI MCP Integration (Recommended)
Before starting development, set up the TakeOff UI MCP server for AI-assisted component discovery and code generation.
Option A: Remote (Recommended - No Installation)
# VS Code Copilot - Add to settings.json
{
"mcp": {
"servers": {
"takeoff-ui-mcp": {
"command": "npx",
"args": ["-y", "mcp-remote", "https://takeoffui.turkishtechlab.com/mcp"]
}
}
}
}
Option B: Local Installation
git clone https://github.com/turkishtechnology/takeoff-ui-mcp.git
cd takeoff-ui-mcp
npm install
npm run build
npm start # STDIO mode
# or
npm run start:stream # HTTP mode (http://127.0.0.1:3845/mcp)
Then configure your editor:
// VS Code Copilot - STDIO
{
"mcp": {
"servers": {
"takeoff-ui-mcp": {
"type": "stdio",
"command": "node",
"args": ["/absolute/path/to/takeoff-ui-mcp/dist/index.js"]
}
}
}
}
// VS Code Copilot - HTTP
{
"mcp": {
"servers": {
"takeoff-ui-mcp": {
"type": "streamable-http",
"url": "http://127.0.0.1:3845/mcp"
}
}
}
}
MCP Capabilities:
get_components_list- Browse all TakeOff UI componentsget_component_info- Detailed docs and examplesget_tailwind_integration- Tailwind setup guidanceget_framework_integration- React/Vue/Angular integrationrefactor_takeoff_ui_code- Code refactoring promptsfigma_to_code- Convert Figma designs to TakeOff UI code
Usage Tip: In your prompts, add "use takeoff-ui-mcp" to leverage MCP tools.
Step 2: Project Scaffolding
Generate the clean file structure (see references/file-structure.md for details):
project-root/
├── src/
│ ├── api/ # API services and clients
│ │ ├── client.ts # Axios/Fetch instance with interceptors
│ │ ├── endpoints/ # API endpoint definitions
│ │ └── types/ # API request/response types
│ ├── auth/ # Authentication logic
│ │ ├── AuthProvider.tsx
│ │ ├── useAuth.ts
│ │ ├── oauth.ts # OAuth 2.0 flows
│ │ └── jwt.ts # JWT handling
│ ├── hooks/ # Custom React hooks (non-API)
│ │ ├── useLocalStorage.ts
│ │ └── useDebounce.ts
│ ├── components/ # Reusable UI components
│ │ ├── DataTable/ # Generic data table
│ │ ├── DynamicForm/ # Schema-driven form
│ │ └── Layout/ # Layout components
│ ├── pages/ # Page components (routes)
│ │ ├── Dashboard/
│ │ ├── Users/
│ │ └── Settings/
│ ├── routes/ # TanStack Router configuration
│ │ └── index.tsx
│ ├── lib/ # Utilities and helpers
│ │ ├── cn.ts # Tailwind class merger
│ │ └── validators.ts
│ ├── types/ # Shared TypeScript types
│ └── main.tsx # Entry point
├── vite.config.ts
├── tailwind.config.ts
└── tsconfig.json
Create this structure:
mkdir -p src/{api/{endpoints,types},auth,hooks,components/{DataTable,DynamicForm,Layout},pages,routes,lib,types}
Step 3: Install Dependencies
# Core packages
npm install @takeoff-ui/core @takeoff-ui/react
# TanStack ecosystem
npm install @tanstack/react-query @tanstack/react-router @tanstack/router-devtools @tanstack/react-query-devtools
# Utilities
npm install axios zod clsx tailwind-merge
# Dev dependencies
npm install -D @types/react @types/react-dom vite @vitejs/plugin-react typescript tailwindcss postcss autoprefixer
Step 4: Configure Vite
See assets/vite.config.ts for template.
Step 5: Configure Tailwind with TakeOff UI
See assets/tailwind.config.ts for template with TakeOff UI plugin integration.
Step 6: Setup TakeOff UI
// src/main.tsx
import '@takeoff-ui/core/dist/core/core.css'
import { createRoot } from 'react-dom/client'
import App from './App'
createRoot(document.getElementById('root')!).render(<App />)
Step 7: Configure TanStack Query
See references/tanstack-patterns.md for setup and usage patterns.
Step 8: Configure TanStack Router
See references/tanstack-patterns.md for router setup.
Step 9: Setup Authentication
Choose auth strategy and implement (see references/auth-patterns.md):
- OAuth 2.0 - For enterprise SSO (Azure AD, Auth0, Okta)
- JWT - For traditional token-based auth
Step 10: Setup Centralized API Client
See references/api-architecture.md for implementation.
Development Workflow
Creating a New Page
- Define the API endpoint in
src/api/endpoints/ - Create TanStack Query hooks for data fetching
- Build the page component in
src/pages/ - Add the route in TanStack Router
- Use TakeOff UI components from approved list
Example:
// 1. API endpoint
// src/api/endpoints/users.ts
export const usersApi = {
getAll: () => apiClient.get('/users'),
getById: (id: string) => apiClient.get(`/users/${id}`),
create: (data: CreateUserDto) => apiClient.post('/users', data),
}
// 2. Query hooks
// src/api/endpoints/users.ts
export const useUsers = () => {
return useQuery({
queryKey: ['users'],
queryFn: usersApi.getAll,
})
}
// 3. Page component
// src/pages/Users/UsersPage.tsx
import { DataTable } from '@/components/DataTable'
import { useUsers } from '@/api/endpoints/users'
export default function UsersPage() {
const { data, isLoading } = useUsers()
return (
<DataTable
data={data}
endpoint="/users"
columns={['name', 'email', 'role']}
enableFilters
enablePagination
/>
)
}
Dynamic UI Generation
See references/dynamic-ui-generation.md for:
- Schema-driven forms - Backend defines fields, frontend renders
- Dynamic tables - API metadata controls columns, filters, badges
- Auto-validation - Backend schemas → frontend validators
Quick Example:
// Backend sends schema with API response
const schema = {
fields: [
{ name: 'firstName', type: 'text', required: true },
{ name: 'email', type: 'email', required: true },
{ name: 'role', type: 'select', options: ['admin', 'user'] }
]
}
// Frontend automatically renders
<DynamicForm schema={schema} onSubmit={handleSubmit} />
Component Usage Guidelines
Before Using a New TakeOff UI Component:
-
Check the TakeOff UI docs or use MCP:
Use takeoff-ui-mcp: Show me DataTable component with examples -
Request approval with justification:
- "I need
TkDataGridbecause it has built-in filtering that reduces 50 lines of custom code" - "Should I use
TkModalorTkDialogfor this use case?"
- "I need
-
Wait for confirmation before implementing
-
Document usage in component file:
/** * Uses TkButton from TakeOff UI * Approved: 2026-01-21 * Reason: Standard button with built-in loading states */
Styling with Tailwind
CRITICAL: NO CSS FILES
// ✅ CORRECT - Tailwind utilities
<div className="flex items-center justify-between p-4 bg-gray-100 rounded-lg">
<TkButton label="Submit" className="px-6 py-2 bg-blue-600 hover:bg-blue-700" />
</div>
// ❌ WRONG - Custom CSS
// Never create styles.css or use <style> tags
// ✅ CORRECT - Dynamic classes
const buttonClass = cn(
'px-4 py-2 rounded-md',
isPrimary && 'bg-blue-600 text-white',
isDisabled && 'opacity-50 cursor-not-allowed'
)
Use the cn() utility (see assets/lib/cn.ts) to merge Tailwind classes:
import { cn } from '@/lib/cn'
const className = cn(
'base-classes',
condition && 'conditional-classes',
props.className // Allow parent overrides
)
Advanced Patterns
API Integration with TanStack Query
See references/tanstack-patterns.md for:
- Query configuration and caching strategies
- Mutation patterns with optimistic updates
- Infinite queries for pagination
- Dependent queries
- Query invalidation strategies
Authentication Flows
See references/auth-patterns.md for:
- OAuth 2.0 Authorization Code Flow
- JWT refresh token rotation
- Protected routes with TanStack Router
- Token storage and security
- API interceptors for auth headers
Backend-Frontend Contracts
See references/dynamic-ui-generation.md for:
- OpenAPI/Swagger schema integration
- JSON Schema validation
- Automatic form field generation
- Type generation from backend schemas
- Runtime validation with Zod
Error Handling
// Centralized error handling in API client
apiClient.interceptors.response.use(
response => response,
error => {
if (error.response?.status === 401) {
// Redirect to login
router.navigate({ to: '/login' })
}
// Show toast notification
toast.error(error.response?.data?.message || 'An error occurred')
return Promise.reject(error)
}
)
// Component-level error handling
const { data, error, isError } = useUsers()
if (isError) {
return <ErrorBoundary error={error} />
}
Performance Optimization
- Code splitting with TanStack Router lazy loading
- Query prefetching on route navigation
- Optimistic updates for instant UI feedback
- Virtual scrolling for large lists (TakeOff UI DataGrid)
- Debounced search inputs
Component Reference Workflow
When you need to match a design reference:
- Analyze the design - Identify UI patterns (table, form, modal, etc.)
- Search TakeOff UI - Use MCP or docs to find matching components
- Propose mapping - "Design shows a data grid → I recommend
TkDataGridwith filters" - Request approval - Get confirmation before implementing
- Implement with Tailwind - Use only TakeOff UI + Tailwind utilities
- If no match exists - Propose creating a composite component OR request new TakeOff component
Example Workflow:
User: "Build this design: [image of user management table]"
You:
1. Analyzing design... I see:
- Data table with sortable columns
- Filter dropdowns for role/status
- Action buttons (edit, delete)
- Pagination
2. TakeOff UI component search...
"use takeoff-ui-mcp: Show me data table components"
3. Recommendation:
- TkDataGrid for the main table (has built-in sorting, filtering)
- TkButton for actions
- TkBadge for status indicators
4. Approval request:
"I recommend using TkDataGrid, TkButton, and TkBadge.
This approach eliminates ~200 lines of custom table logic. Approved?"
5. After approval → Implement with Tailwind styling
Security Best Practices
- Never store tokens in localStorage - Use httpOnly cookies or secure storage
- Validate all API responses - Use Zod schemas
- Sanitize user inputs - Especially in dynamic forms
- Implement CSRF protection - For state-changing operations
- Use HTTPS only - Enforce in production
- Implement rate limiting - On auth endpoints
- Audit dependencies - Regular
npm audit
Quality Checklist
Before considering a page/feature complete:
- No custom CSS files created
- All TakeOff UI components approved
- TypeScript strict mode passing
- API calls use centralized client
- Auth tokens managed securely
- Error states handled gracefully
- Loading states implemented
- Responsive design (Tailwind breakpoints)
- Accessibility tested (keyboard navigation, screen readers)
- Form validation working (client + server)
- Query invalidation on mutations
- Route guards for protected pages
- No hardcoded API URLs (use env variables)
- Dynamic UI uses backend schemas where applicable
Troubleshooting
TakeOff UI Not Rendering
// Ensure core CSS is imported in main.tsx
import '@takeoff-ui/core/dist/core/core.css'
// For Next.js, add to app/layout.tsx or page.tsx
import '@takeoff-ui/core/dist/core/core.css'
TanStack Router Type Errors
# Generate route types
npx tsx ./src/routes/index.tsx
Auth Token Refresh Issues
See references/auth-patterns.md for token refresh interceptor implementation.
TakeOff UI MCP Not Connecting
# Check MCP server status
curl http://127.0.0.1:3845/health
curl http://127.0.0.1:3845/info
# Debug logs
# In .env: LOG_LEVEL=0
# Verify absolute paths in config
# WRONG: "args": ["./dist/index.js"]
# RIGHT: "args": ["/full/path/to/takeoff-ui-mcp/dist/index.js"]
Quick Reference
Common Commands
# Development
npm run dev
# Build
npm run build
# Type check
npm run type-check
# Lint
npm run lint
# TakeOff UI MCP (local)
npm start # STDIO mode
npm run start:stream # HTTP mode
File Templates
- assets/vite.config.ts - Vite configuration
- assets/tailwind.config.ts - Tailwind + TakeOff plugin
- assets/api-client.ts - Centralized API client
- assets/AuthProvider.tsx - Auth context provider
- assets/DataTable.tsx - Generic data table component
- assets/DynamicForm.tsx - Schema-driven form
Reference Documentation
- references/file-structure.md - Complete project structure guide
- references/tanstack-patterns.md - Query & Router patterns
- references/api-architecture.md - API client design
- references/dynamic-ui-generation.md - Schema-based UI patterns
- references/auth-patterns.md - OAuth & JWT implementations
- references/takeoff-components.md - Common component usage
External Resources
- TakeOff UI Documentation
- TakeOff UI Components
- TakeOff UI Tailwind Plugin
- TakeOff UI MCP Server
- TanStack Query Docs
- TanStack Router Docs
- Tailwind CSS Docs
Summary
This skill enforces a clean, scalable architecture for React frontends with:
- TakeOff UI components - Enterprise-grade, Tailwind-integrated
- TanStack Query & Router - Modern data fetching and routing
- Centralized API & Auth - Secure, maintainable integrations
- Dynamic UI generation - Backend schemas drive frontend
- Tailwind-only styling - No custom CSS complexity
- Strict separation - Services, hooks, components, pages isolated
- Type safety - TypeScript throughout
- MCP assistance - AI-powered component discovery
Follow the workflows, request component approval, and maintain clean architecture. The result: production-ready, secure, maintainable React applications.