- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.3k
 
docs(examples): add serialization documentation to Supabase example #5685
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
docs(examples): add serialization documentation to Supabase example #5685
Conversation
Add comprehensive documentation explaining server function serialization requirements when using Supabase with TanStack Start. Changes: - Add README.md with setup guide and serialization best practices - Add 40+ line JSDoc comment in __root.tsx explaining serialization constraints - Improve error handling (log errors instead of suppressing with _error) - Add inline examples showing correct vs incorrect patterns - Add commented examples for safely adding more user fields Fixes TanStack#3831 The code in the Supabase example is functionally correct, but lacked documentation explaining the serialization requirements for server functions. This caused confusion for developers who wanted to return additional user fields from Supabase. This PR helps developers understand: - Why only primitive values can be returned from server functions - What Supabase user objects contain (non-serializable data) - How to safely add more fields - Common errors and their solutions Testing: - Verified with real Supabase credentials - Confirmed no hydration errors exist - Confirmed no serialization errors in current implementation - Code pattern is correct, documentation was missing 🤖 Generated with Claude Code Co-Authored-By: Claude <[email protected]>
          
WalkthroughThis PR adds a new README documenting the TanStack Start + Supabase Basic example and updates  Changes
 Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 
 Suggested labels
 Suggested reviewers
 Poem
 Pre-merge checks and finishing touches❌ Failed checks (1 warning)
 ✅ Passed checks (4 passed)
 ✨ Finishing touches
 🧪 Generate unit tests (beta)
 Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment   | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
examples/react/start-supabase-basic/README.md (2)
7-12: Fix markdown linting issues in setup section.The bare URL and code block without language specifier trigger markdown linting warnings. While these don't affect functionality, addressing them improves documentation consistency.
Apply this diff:
-1. Create a Supabase project at https://supabase.com +1. Create a Supabase project at [Supabase](https://supabase.com) 2. Copy `.env` and fill in your Supabase credentials: - ``` + ```bash SUPABASE_URL=your-project-url SUPABASE_ANON_KEY=your-anon-key ```
100-100: Add language specifier to project structure code block.Apply this diff:
-``` +```text src/ ├── routes/
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
examples/react/start-supabase-basic/README.md(1 hunks)examples/react/start-supabase-basic/src/routes/__root.tsx(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
examples/{react,solid}/**
📄 CodeRabbit inference engine (AGENTS.md)
Keep example applications under examples/react/ and examples/solid/
Files:
examples/react/start-supabase-basic/README.mdexamples/react/start-supabase-basic/src/routes/__root.tsx
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use TypeScript in strict mode with extensive type safety across the codebase
Files:
examples/react/start-supabase-basic/src/routes/__root.tsx
**/src/routes/**
📄 CodeRabbit inference engine (AGENTS.md)
Place file-based routes under src/routes/ directories
Files:
examples/react/start-supabase-basic/src/routes/__root.tsx
🧬 Code graph analysis (1)
examples/react/start-supabase-basic/src/routes/__root.tsx (1)
examples/react/start-supabase-basic/src/utils/supabase.ts (1)
getSupabaseServerClient(4-24)
🪛 markdownlint-cli2 (0.18.1)
examples/react/start-supabase-basic/README.md
7-7: Bare URL used
(MD034, no-bare-urls)
9-9: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
100-100: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
🔇 Additional comments (7)
examples/react/start-supabase-basic/README.md (4)
16-60: Excellent documentation of serialization requirements.This section clearly explains the serialization constraints and provides practical examples. The distinction between serializable primitives and non-serializable types (functions, class instances, Date objects) is accurate and well-presented.
61-97: LGTM! Practical troubleshooting guide.The common errors section addresses real issues developers will encounter. The code examples show clear before/after patterns, and the
?? nulloperator usage is idiomatic for handling undefined values.
120-169: LGTM! Implementation examples are accurate.The "How It Works" section provides clear explanations with code examples that match the actual implementation. The emphasis on serialization in the fetchUser example (line 134) reinforces the key concept introduced earlier.
170-196: LGTM! Helpful resources and troubleshooting tips.The documentation links and troubleshooting section provide good next steps for developers. The deployment platform compatibility list is accurate for TanStack Start applications.
examples/react/start-supabase-basic/src/routes/__root.tsx (3)
18-53: Excellent inline documentation for serialization requirements.This comprehensive JSDoc comment provides clear guidance right where developers need it. The examples of wrong vs correct patterns, along with the serializable types reference, will help prevent the common serialization errors this PR aims to address.
54-62: LGTM! Improved error handling with explicit logging.The change from
_error(intentionally ignored) toerrorwith explicitconsole.errorlogging is a debugging improvement. The contextual prefix[fetchUser]makes error source identification easier during troubleshooting.
64-77: LGTM! Serialization implementation is correct and well-documented.The return statement correctly extracts only primitive fields from the Supabase user object. The commented examples provide clear guidance for safely adding additional fields, including the
?? nullpattern for handling potentially undefined values fromuser_metadata.
Summary
Adds comprehensive documentation explaining server function serialization requirements when using Supabase with TanStack Start.
Problem
The Supabase example works correctly but lacks documentation explaining why only primitive values are returned from the
fetchUserserver function. This causes confusion for developers who want to add more user fields.Changes
1. New
README.md(245 lines)2. Enhanced
__root.tsxWhat's Serializable?
"hello"42truenull{ name: "Alice" }[1, 2, 3]Testing
Fixes
Fixes #3831
Additional Context
The existing code is functionally correct - it already returns only the
emailfield (a primitive). This PR adds the missing documentation that explains:This helps developers understand the pattern and avoid mistakes when extending the example.
🤖 Generated with Claude Code
Co-Authored-By: Claude [email protected]
Summary by CodeRabbit
Documentation
Bug Fixes