feat: supabase sdk references #27
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce?
Adds comprehensive Supabase JS SDK reference documentation.
What is the current behavior?
The Supabase skill previously focused on database-level patterns (RLS policies, schema design, migrations, performance optimization). While it covered essential backend patterns, it lacked guidance for frontend developers working with the supabase-js SDK, including:
{ data, error }API patternThis gap meant developers had to frequently consult external documentation for SDK-specific patterns.
What is the new behavior?
Added 14 new reference files under
skills/supabase/references/sdk/organized into 6 logical sections:Client Initialization (CRITICAL):
createBrowserClientcreateServerClientTypeScript (HIGH):
Query Patterns (HIGH):
Error Handling (MEDIUM-HIGH):
Performance (HIGH):
Framework Integration (HIGH):
Decisions
Key architectural and content decisions made during development:
Organized by usage pattern rather than API method: Instead of documenting each SDK method alphabetically (select, insert, update, etc.), grouped references by how developers actually work - setting up clients, writing queries, handling errors, optimizing performance. This matches the mental model of building features rather than learning API surfaces.
Emphasized @supabase/ssr over deprecated packages: Explicitly called out that
@supabase/auth-helpers-nextjsis deprecated and demonstrated correct patterns with@supabase/ssr. UsedgetAll()/setAll()cookie methods instead of individual cookie operations, which is the current best practice for Next.js 13+.Focus on Incorrect/Correct pattern format: Each reference follows a consistent structure showing common mistakes first, then the correct approach. This addresses real pain points developers face (e.g., creating multiple client instances, forgetting error checks, missing subscription cleanup).
Separate browser vs server client patterns: Created distinct references for browser and server contexts because they use different packages (
createBrowserClientvscreateServerClient) and have different singleton/cookie requirements. This prevents confusion around when to use which approach.Prioritized realtime cleanup patterns: Realtime subscription memory leaks are a common issue in React applications. Dedicated a full reference to proper cleanup with
useEffectdependency handling andremoveChannel()patterns.Progressive disclosure from SKILL.md: Kept SKILL.md lean with just the resources table pointing to detailed SDK references. The body of SKILL.md focuses on core concepts, while SDK-specific patterns live in dedicated reference files that load on demand.
Additional context
Sources consulted:
Framework focus:
Started with Next.js App Router as the primary framework example since it represents the current best practice for React SSR. Future PRs could add framework-specific references for Remix, SvelteKit, Nuxt, etc.
Type safety emphasis:
TypeScript type generation is marked HIGH impact because it provides compile-time safety for all database operations. The workflow includes CLI commands for both local and remote type generation, plus CI/CD integration patterns.
Realtime scale considerations:
Documented the single-thread limitation of Postgres Changes and recommended using Broadcast for high-throughput scenarios. Included filter patterns to reduce server load by filtering at the source.