Storing user data locally after login

I’m building a Next.js app using Auth0 as the authentication system (web app with Google OAuth). Users are logged in using the standard middleware:

import { withMiddlewareAuthRequired } from '@auth0/nextjs-auth0/edge';

export default withMiddlewareAuthRequired() 

However, I’d like to maintain some information about the user in my local database (for instance, mapping an auth0 userId to a local userId in order to attach relationships to that user, or being able to easily list related users to the current user). My question however, surrounds how to do this.

From digging it seems that using things like 'handleCallback` might be the way to go, but I’m struggling to get this working with Next (being quite new to it).

For instance:

import { handleAuth, handleCallback } from "@auth0/nextjs-auth0";

const afterCallback = async (req, res, session, state) => {
  /// do database things
  return session;
}

const auth = handleAuth({
  async callback(req, res) {
    await handleCallback(req, res, { afterCallback })
  }
});

export { auth as GET, auth as POST }

However, this always gives me:

Error: No response is returned from route handler 'blah/app/api/auth/[auth0]/route.js'. Ensure you return a `Response` or a `NextResponse` in all branches of your handler.

Firstly, is this the right way to go about doing this, and if not, what is?