Add username to signup flow
Hi. I have set up a project with the default Gadget.dev user signup/signin flow. I would like to add a required username parameter (next to the default email address and password parameters) for new users. However, in the user.signUp action, I can’t seem to retrieve any parameter from the parameter object next to email and password. How can I fix this?
7 Replies
Now that I think of it, would it be correct to add this to the signUp action:
/** @type { ActionParams } */
export const params = {
username: { type: "string" }
};
I think that you should instead be passing a state query param in the signup redirect. Then you can access it from the request object in action context.
I don't know if the additional params would work but you can always also try that. Note that you'll need to update the fields on the form of the sign up page

Okido, thank you. Will try that.
you want to pass the username as part of google signup or by using the email/password flow using the
signUp
action directly?
For using the signUp
action directly you pass your parameters like any other
For google oauth you can pass parameters in the query parameters to start url: https://docs.gadget.dev/guides/plugins/authentication/helpers#custom-auth-state-parametersHelpers - Developer Docs - Gadget
Gadget Docs
I would like to pass them to the signUp action directly
The issue seems to be that the emailSignUp trigger removes all parameters but the email and password
ok this is a miss on our part from a DX point of view
this is what I have in my
api/models/user/actions/signUp.ts
note that we put the custom params at the top level and not under the params.user
key 🙁
gotta talk to the team about what the ideal UX should be; but for now this should solve your problemThank you very much
And indeed, this solves my issue. Awesome!