Account linking with next-auth (Next.js)

Hello Auth0 Community,

I’m currently working on a project using Next.js and next-auth for authentication. Auth0 is the only provider in next-auth configuration.

I’m trying to link user accounts so that a user can sign in with multiple social connections (e.g. Google, Facebook, etc.) using the same or different email address.

The current flow is, when the user is authenticated with Google, there will a be “Link with Facebook” button for them to initiate the account linking process.
Once the user clicked the button, I called

import { signIn } from 'next-auth/react';
signIn('auth0', null ,{ connection: 'facebook' });

However, after successful login with Facebook, next-auth treats user logged in with FaceBook and I can only retrieve account info of Facebook, which is not enough for me to call /api/v2/users/{id}/identities endpoints.

Does anyone have experience using Next-Auth for account linking? Could you point me to any resources or examples that might be helpful? Or perhaps provide some guidance on how to set it up?

Thank you in advance for any help.

I have the same use-case. Are you had success and can share some code? Thanks!