Supabase Frontend Integration
Connect React frontend pages to Supabase database with TypeScript, React Query, and proper error handling. Use when integrating Supabase with website pages, setting up database queries, or replacing mock data with real data from events, bookings, menu_items, or profiles tables.
$ Installieren
git clone https://github.com/amo-tech-ai/skybox-gamehub /tmp/skybox-gamehub && cp -r /tmp/skybox-gamehub/.claude/skills/supabase-frontend ~/.claude/skills/skybox-gamehub// tip: Run this command in your terminal to install the skill
name: Supabase Frontend Integration description: Connect React frontend pages to Supabase database with TypeScript, React Query, and proper error handling. Use when integrating Supabase with website pages, setting up database queries, or replacing mock data with real data from events, bookings, menu_items, or profiles tables.
Supabase Frontend Integration
Quick start
Connect a page to Supabase in three steps:
- Create hook: Write React Query hook for data fetching
- Update component: Replace mock data with hook
- Add states: Handle loading, error, and empty states
File structure
src/
âââ lib/
â âââ supabase.ts # Client config (already exists)
â âââ formatters.ts # Date/time helpers
âââ hooks/
â âââ useEvents.ts # Events queries
â âââ useBookings.ts # Booking mutations
â âââ useMenu.ts # Menu queries
âââ pages/
âââ Index.tsx # Home page
âââ Schedule.tsx # Events list
âââ Menu.tsx # Menu items
âââ Reserve.tsx # Create bookings
Database tables reference
See TABLES.md for complete schema with field names and types.
Common patterns
Pattern 1: Fetch list of items
Use for: Events page, menu page, customer list
See FETCH_LIST.md for complete examples.
Pattern 2: Create new record
Use for: Reserve page, contact form
See CREATE_RECORD.md for mutation patterns.
Pattern 3: Update existing record
Use for: Edit profile, update booking
See UPDATE_RECORD.md for update examples.
Error handling checklist
When adding Supabase queries:
- [ ] Loading state shows spinner
- [ ] Error state shows message with retry
- [ ] Empty state shows friendly message
- [ ] Success state displays data correctly
- [ ] RLS policies allow query (check Supabase dashboard)
Validation workflow
For critical operations (bookings, payments):
- Create data in hook
- Validate response has no errors
- Update UI optimistically
- Revert on failure
See VALIDATION.md for implementation details.
Environment setup
Required environment variables in .env.local:
VITE_SUPABASE_URL=https://project-id.supabase.co
VITE_SUPABASE_ANON_KEY=eyJhbGc...
For Vercel deployment, add same variables in project settings.
Real-time updates
For dashboard pages needing live data:
See REALTIME.md for subscription patterns.
Troubleshooting
401 Unauthorized: Add RLS policy in Supabase Dashboard
No data returned: Check table has published records with correct status
Type errors: Regenerate types with npx supabase gen types typescript
Slow queries: Add index on filtered/sorted columns
See TROUBLESHOOTING.md for complete solutions.
Repository
