Fix Sign-In/Sign-Up Button Visibility, Hydration Delay & Cache Behaviour #359
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.
Summary
This PR fixes the long-standing issue where Sign-In/Sign-Up buttons failed to appear reliably on production or appeared with noticeable delay.
The fix addresses three root causes:
This PR introduces improvements across:
✔ Authentication initialization
✔ Header loading UI
✔ Cache configuration
✔ Overall perceived performance
✅ 1. Authentication Hook Optimization
File:
lib/hooks/useAuth.tsWhat Changed
isHydratedstateuseEffectImpact
✅ 2. Header Skeleton UI Improvements
File:
components/header.tsxWhat Changed
"Loading..."with skeleton button placeholders70×34px&75×34px)animate-pulsekey={user.id}to ensure user menu re-renders correctlyImpact
✅ 3. Cache Header Enhancements
File:
next.config.tsHomepage (
/)Cache-Control: no-cache, no-store, must-revalidateVary: Cookie, Accept-EncodingGeneral HTML pages
Cache-Control: public, max-age=0, must-revalidateVary: Cookiefor correct per-user cachingDynamic pages (events/hackathons/etc.)
Vary: Cookieto prevent cross-user HTML reuseImpact
🧪 Testing Completed
Local Testing
Production Testing
X-Build-ID,Cache-Control,Vary📈 Performance Improvements
✔ Additional Notes
🚀 Ready for Review
This PR significantly improves authentication responsiveness, eliminates caching inconsistencies, and provides a polished loading experience across the site.
Authored by: @akshay0611
Summary by CodeRabbit
Release Notes
New Features
Performance Improvements
✏️ Tip: You can customize this high-level summary in your review settings.