v0.4.3 - DX Improvements from Real Production Feedback
🎯 DX Improvements Based on Scout Integration
This release addresses critical developer experience issues discovered during real production integration.
✨ New Helper Functions
Better TypeScript Support:
requireServerSession()- Get authenticated session or throw (no more!assertions)isLatchSession()- Type guard for proper TypeScript narrowingcheckLatchHealth()- Configuration validation for health check endpoints
🐛 Critical Fixes
Next.js 16 Compatibility:
- ❌ Fixed:
export const runtime = 'nodejs'causes build errors in proxy.ts - ✅ proxy.ts automatically uses Node.js runtime (no config needed)
Session Validation:
- ❌ Fixed: Examples checking
session.idToken(property doesn't exist) - ✅ Check
session.subinstead (from ID token claims)
📚 Documentation
New Reference Implementation:
examples/nextjs16/proxy.ts- Complete Next.js 16 proxy with proper session validation
Enhanced API_REFERENCE.md:
- Clear LatchSession/LatchUser structure documentation
- ✅ Correct vs ❌ Wrong usage examples
- Cookie name constants documentation
- Session validation patterns for proxy.ts
🧪 Testing
- Added 17 new tests for DX helpers
- All 182 tests passing
- No breaking changes
📦 What Changed
Added:
requireServerSession()helperisLatchSession()type guardcheckLatchHealth()config validator- Reference proxy.ts for Next.js 16
- Comprehensive session documentation
Fixed:
- Next.js 16 proxy.ts runtime export issue
- Session validation patterns in examples
- Documentation clarity on session structure
🙏 Credits
Based on real production feedback from integrating Latch into Scout app. Thanks for the 2.5 hours of pain points that made this release possible!
📖 Links
- 📦 npm: https://www.npmjs.com/package/@lance0/latch
- 📚 Documentation: https://github.com/lance0/latch
- 🐛 Issues: https://github.com/lance0/latch/issues