Update user after calling updateSession in Next.js

In my backend I have(/api/add-db-users.ts):

 await updateSession(req, res, {
      user: { ...session.user, 'https://localhost:3000.com/appmetadata': { localUserCreated: true } },
    const session2 = await getSession(req, res)
    console.log('session2', session2)

session2 shows the updated appmetadata property. But when I call,

const session = await getSession(req, res)

anywhere else in the app, it has the old data. if I sign out then back in, the data is there.

How can I update the appmetadata field and get that updated value throughout my Next.js app?

I’m using

"@auth0/nextjs-auth0": "^2.0.0",
"next": "13.0.2",

Hi @brandon2,

Welcome to the Auth0 Community!

This is an expected behavior. To get the user’s latest state, I recommend configuring Silent Authentication. This way, you can get new tokens with the freshest data and without any user interaction.

Please let me know if you have any questions or need help with implementation.


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.