Segment Analytics + Next Auth
Unanswered
Argentine ant posted this in #help-forum
Argentine antOP
Hi there,
We're trying to setup Segment analytics (analytics.js) with Next 13 app router and NextAuth. The next auth flow is straightforward but we can't find a way to get a
The only thing we can think to do so far is use
Anyone know how to get a sign in callback on the client after a user authenticates or somewhere we could detect an auth change that isn't run on every single page load?
Thanks!
We're trying to setup Segment analytics (analytics.js) with Next 13 app router and NextAuth. The next auth flow is straightforward but we can't find a way to get a
signIn callback on the client side that would allow us to call analytics.identify and make sure that the Segment JS SDK has the proper user ID associated with it.The only thing we can think to do so far is use
useSession to pull the user ID and call. identify on every page load, or something hacky that stores the last identified user ID and only identifies when useSession returns a different user ID. Either way, we need to run this on every page load which feels very hacky.Anyone know how to get a sign in callback on the client after a user authenticates or somewhere we could detect an auth change that isn't run on every single page load?
Thanks!