chore: Upgrade better-auth to v1.4#84
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughDependencies updated in package.json (better-auth ^1.2.12→^1.4.7, drizzle-orm ^0.44.3→^0.41.0). Auth handlers in authContext.tsx wrapped with useCallback for memoization; signOut flow refactored to delegate navigation to fetchOptions.onSuccess callback. Auth configuration structure adjusted to nest generateId under database object per updated better-auth version requirements. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 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 |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (3)
package.json(1 hunks)src/contexts/authContext.tsx(4 hunks)src/utils/auth.ts(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-07-17T23:34:25.074Z
Learnt from: seancheong
Repo: seancheong/tripa PR: 55
File: src/contexts/authContext.tsx:19-31
Timestamp: 2025-07-17T23:34:25.074Z
Learning: In OAuth authentication flows using better-auth/react that trigger redirects to external providers (like GitHub), the loading state should intentionally remain true after the sign-in call to prevent users from clicking the sign-in button multiple times during the brief window before redirect. The loading state resets naturally when the component unmounts during navigation to the OAuth provider's screen.
Applied to files:
src/contexts/authContext.tsx
📚 Learning: 2025-07-21T04:32:55.979Z
Learnt from: seancheong
Repo: seancheong/tripa PR: 64
File: src/features/location/contexts/locationContext.tsx:14-18
Timestamp: 2025-07-21T04:32:55.979Z
Learning: seancheong prefers to use default values when creating React contexts rather than undefined, as seen in the LocationContext implementation in src/features/location/contexts/locationContext.tsx. The current pattern with default object values is valid and works correctly with proper error checking in the custom hook.
Applied to files:
src/contexts/authContext.tsx
🔇 Additional comments (6)
src/contexts/authContext.tsx (4)
1-1: Good use of type import for User.Using
typeimport is a best practice that helps with tree-shaking and clarifies thatUseris only used as a type.
4-10: LGTM: Import additions support memoization.The addition of
useCallbackand reorganization of imports is appropriate for the memoization improvements in this file.
35-48: LGTM: githubSignIn properly memoized.The useCallback memoization with an empty dependency array is correct since there are no external dependencies. The loading state intentionally remains
trueafter sign-in to prevent multiple clicks during OAuth redirect, which aligns with established patterns.Based on learnings, the loading state behavior during OAuth redirects is intentional.
50-63: LGTM: googleSignIn properly memoized.The useCallback memoization with an empty dependency array is correct. Consistent with the githubSignIn implementation.
src/utils/auth.ts (1)
17-19: Configuration structure is correct for better-auth v1.4.7.The nesting of
generateIdunderadvanced.databaseis the current API standard following the v1.4 upgrade. This represents the migration away from the deprecatedadvanced.generateIdoption to the newadvanced.database.generateIdpattern.package.json (1)
31-31: No evidence supports the need for this downgrade. The codebase uses relational queries APIs (relations, db.query.findFirst, db.query.findMany, with) that are available and stable in both v0.41.0 and v0.44.x. Web search found no requirement from better-auth v1.4.7 for drizzle-orm v0.41.0; recent examples show better-auth working with ^0.44.6. Verify whether this downgrade is actually intentional or if ^0.44.3 should be retained.Likely an incorrect or invalid review comment.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.