Consistent Signup Event Tracking Across Auth Methods
I’m trying to track signup events across all auth methods (email/password, magic link, OAuth) using Better Auth hooks. Email signups work fine, but I can’t access user data after OAuth callbacks.
Current Implementation
export const auth = betterAuth({
hooks: {
after: createAuthMiddleware(async (ctx) => {
const isSignup =
ctx.path === "/signup" {};
if (user) await trackSignupEvent(user);
}
}),
},
});
What Works

Handling OAuth tracking client-side in the onboarding component, but this is unreliable and misses edge cases...
Environment
Better Auth (latest)
Next.js App Router
PostgreSQL + Prisma
Auth methods: email/password, magic link, Google OAuth
Current Implementation
export const auth = betterAuth({
hooks: {
after: createAuthMiddleware(async (ctx) => {
const isSignup =
ctx.path === "/signup" {};
if (user) await trackSignupEvent(user);
}
}),
},
});
What Works
- Email/Password
- Path: /signup
- ctx.body.user is available → tracking works
- OAuth (e.g., /callback/google)
- How can I reliably access user data during OAuth callbacks? Different hook? Different context properties?
- Are there separate hooks for different auth flows?
- What’s the recommended server-side pattern for consistent signup tracking across methods?
- For OAuth: what properties are exposed in the context, and how do I get the user record?
Handling OAuth tracking client-side in the onboarding component, but this is unreliable and misses edge cases...
Environment
Better Auth (latest)
Next.js App Router
PostgreSQL + Prisma
Auth methods: email/password, magic link, Google OAuth