Supabase React TS
Use this skill to build small MicroSaaS-style apps with a React TSX client, Supabase Auth/Postgres/Edge Functions, strict RLS, local/LAN developer ergonomics, and pragmatic test coverage.
Reference starters:
assets/auth-starter/: default auth-only skeleton for new MicroSaaS products.assets/starter/: Team Tasks worked example for richer app-data, RLS, and command/query patterns.
Core Workflow
- Inspect the target repo first. If it is empty, scaffold from
assets/auth-starter/unless the user explicitly asks for the Team Tasks worked example. - Read
references/project-style.mdbefore making structure, UI, dependency, or testing choices. - Read
references/starter-guide.mdbefore scaffolding, choosing starter mode, renaming, or wiring config. - For auth-only skeletons, run
scripts/scaffold.mjsand skip app-data references until a persisted feature is requested. - For data boundaries, Edge Functions, or request handling, read
references/architecture.md. - For schema, RLS, direct-table access, or security tests, read
references/supabase-security.md. For a tenant-scoped append-only write that combines monotonic ordering with replay-safe retries, also readreferences/supabase-serialized-writes.md. For exact unread or acknowledgement state over that ordered stream, also readreferences/supabase-membership-watermarks.md. - For private Broadcast channels, receive-only Realtime RLS, or externally minted Realtime sessions, read
references/supabase-private-realtime.md. - For a public database-backed health or readiness function, read
references/public-health-endpoints.md. - For runtime config, Netlify builds, or local/LAN scripts, read
references/config-and-deploy.md. - Implement the usable app first, not a marketing page. Keep files small and concerns separated.
- On a fresh host, run the starter's read-only
npm run preflightbefore promising local Supabase, security, or visual validation. - Before schema or security integration tests, run the starter's local migration-alignment gate. A successful
supabase startmay restore persistent database state from another branch and is not proof that the live schema matches the checkout. - Verify with the narrowest meaningful set:
npm run lint,npm test,npm run build, Playwright for UI flows, andnpm run test:securityfor RLS/function changes.
Default Shape
- Client: Vite, React, TypeScript, React Router, SCSS modules.
- Backend: Supabase Auth first; add Postgres migrations, Edge Functions, and RLS as mandatory safety nets when app data is introduced.
- Boundary style: command/query request types, shared identifiers/types in
common, client-side function invoker handlers, and function-side dispatcher handlers once product data crosses the client/function boundary. - Runtime config: committed
public/config.jsloader, committed substitutablepublic/config.json, ignoredpublic/config.local.json, test config undertests/visual. - Deployment setup docs: committed
README.ENV.mdwith placeholder-only Netlify, runtime config, Supabase dashboard, Edge Function, migration, and smoke-check steps whenever the app has hosted runtime config. - Developer workflow:
npm run get-goingstarts dependencies, Docker/Supabase/functions/Vite, validates configured function routes rather than health alone, writes local config, exposes LAN URLs, and prints endpoints.npm run all-donewinds everything down. - Tests: unit tests for pure domain/state, visual tests for core UI, and local Supabase security tests for both Edge Functions and direct publishable-key table access once app tables exist.
Guardrails
- Treat dependencies with skepticism. Prefer official/high-reputation packages already implied by the stack.
- Keep Supabase as an implementation detail behind data/dispatch boundaries in the client.
- Treat an Edge Function name as a URL routing prefix, not exact-path enforcement. Declare the runtime-visible pathname or path set that each function owns before privileged work.
- Do not rely on Edge Functions alone for security. Malicious users can call tables directly with the publishable key; RLS must be correct.
- Prefer semantic HTML, native controls, and reusable layout primitives from
lib/ui. - Use the starter action hierarchy: one clear primary action, quiet supporting actions, destructive intent styling, Lucide icons, and responsive icon/text content.
- Avoid large global stores. Prefer composed hooks, view models, and pure state update helpers.
- Mutating commands should return minimal affected DTOs; explicit queries load explicit state.
- Keep local-only generated files ignored. Do not commit machine-specific LAN config.
- Treat frontend signup visibility and authentication-method flags as presentation capabilities only. Supabase Auth's project-wide and provider-specific signup settings are the authoritative enrolment controls.
- After scaffolding, run a placeholder/name sweep for
Team Tasks|teamTasks|team_tasks|team-tasks|__APP_and fix any unintended matches before finishing.