Unable to persist query param (ref) in Post User Registration Action

I’m trying to pass a ref query parameter during signup using loginWithRedirect({ authorizationParams: { screen_hint: "signup", ref: "xyz" } }), and I want to access that flag in the onExecutePostUserRegistration action.

I tried this code:

js

CopyEdit

exports.onExecutePostUserRegistration = async (event, api) => {
  const ref = event.request.query?.ref;
  if (ref) {
    api.user.setUserMetadata("ref", ref);
  }
};

But it looks like event.request.query is undefined or doesn’t include the query string. I suspect the ref param doesn’t survive the email verification link.

What’s the recommended way to pass a referral flag or other custom data through the signup process and access it in the Post User Registration Action?

I want to avoid a database or session store unless necessary.

Hi @a.bilani

Welcome to the Auth0 Community!

Thank you for posting your question. Unfortunately, the event request.query property is not available in the pre-user registration Action. It’s available in the post-Login Action only. You can read more about that here → Pre-registration Action with event.request.query

I would encourage you to create a new topic in the Product Feedback category, explaining your use case and desired solution. Make sure to vote on your card!

Thanks
Dawid

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