After updating user_metadata on Auth0 server, sync client side useAuth0.user hook with that new metadata

Hello - I think the title says it all, i’ve been trying to figure this out for a couple days but can’t seem to.

In Auth0, my users have a user_metadata field called ‘favorites’ which is an array of GUIDs. When a user clicks the GUID on the client end, that GUID is added to the favorites array for the Auth0 user on the Auth0 server. I have checked the user manually to ensure this is happening.

The problem is that I now need a refreshed snapshot of the user_metadata in my client now that the favorite has been added to the server list. I am using the useAuth0 hook in my react app throughout the app, so I really want to try and keep things streamlined by simply making a call to update useAuth0.user from the server without having to logout and back in again.

Does someone know what the solution to this is? Thanks very much.


1 Like


I’m having the same issue! I’m using @auth0/nextjs-auth0 and after updating the user I call the refetch endpoint (se code below) which updates all fields but user_metadata is always one iteration behind.

Any idea what I am missing here? Thanks in advance :slight_smile:

refetch endpoint:

import { handleProfile } from '@auth0/nextjs-auth0';
import { NextApiRequest, NextApiResponse } from "next";

export default async function refetch(req: NextApiRequest, res: NextApiResponse) {
  try {
    await handleProfile(req, res, {
      refetch: true
  } catch (error: any) {
    res.status(error.status || 500).end(error.message);

Hey there!

As this topic is related to Rules - Hooks - Actions and Rules & Hooks are being deprecated soon I’m excited to let you know about our next Ask me Anything session in the Forum on Thursday, January 18 with the Rules, Hooks and Actions team on Rules & Hooks and why Actions matter! Submit your questions in the thread above and our esteemed product experts will provide written answers on January 18. Find out more about Rules & Hooks and why Actions matter! Can’t wait to see you there!

Learn more here!