After hook for social logins, newSession is null?
When I sign up with my social accounts,
ctx.context.newSession
is always null
in the after hook. Is this intended? If so, how can I handle https://www.better-auth.com/docs/concepts/hooks#example-send-a-notification-to-your-channel-when-a-new-user-is-registered but for social? It works fine for e.g. email otpHooks | Better Auth
Better Auth Hooks let you customize BetterAuth's behavior
Solution:Jump to solution
newSession on social logins is generated on
/callback
path not on /sign-in/social
4 Replies
Solution
newSession on social logins is generated on
/callback
path not on /sign-in/social
Is there a way to get the provider (e.g. google, facebook) in this hook?
you can get it from the path.
ctx.path
will have /callback/:providerId
I tried logging it before but it just shows
'/callback/:id'
, so I guess you need to get it from somewhere else or am I just being stupid
Params I guess, lemme check
Yeah got it, thanks