User referral codes

I would like to know if there is a native functionality for users to invite people to our platform and register with Kinde that come from that user through some system.
16 Replies
IkiTg07
IkiTg073mo ago
Hello, unfortunalety no but it's something i've myself asked in the past so I know it's somewhere in their plan. I'll let them know others are asking for it tho
Samuel Corsan
Samuel CorsanOP3mo ago
Thanks @IkiTg07 But do you know if there is a way to do it? Either it has to be outside Kinde, like with the user properties or I don't know, its metadata, or it has to be in my db and that's it.
IkiTg07
IkiTg073mo ago
So ive done it twice First time I just created a special link with referral and sent it via SMS or email Second I created the user in kinde using the management api and sent an email for the user to sign in for the account verification. I guess with this method you could wait until the invited user verifies his profile before adding it to the DB So the first time with the referal code inside the url sent to the user i'd check upon signing-up in the callback if there's a referral in the url to use it for other logic (I was using it to flag the referee to its referrer for a fidelity and referral system)
Samuel Corsan
Samuel CorsanOP3mo ago
Is it not possible to pass extra props to the form? I mean, for example if the user has the parameter in the URL ?link=12345678 that in the <RegisterLink /> in nextjs or something like that you can put a parameter 12345678 and when the hook of user.created that I have put can be obtained that data and save them in the db. Is there anything like this? and how do you know who invited the new user?
IkiTg07
IkiTg073mo ago
I' encoded the params to retrieve the referer id inside later The RegisterLink component from kinde can take postredirecturl as a prop so you'd have to use the post redirect url to which you'll attach your param
Samuel Corsan
Samuel CorsanOP3mo ago
But Can I add parameters to send to the register link Or how to encode the params or where to add them to later get them I don’t understand the complete flow Is there a doc for this?
IkiTg07
IkiTg073mo ago
Gimme a minute i'll try to be more concise I did it using custom sign-in/up but it should work even with kinde's default pages you'll just need a little extra So what I did when making an invitation auth flow was : - create an invitation link like
www.my-domain.com?ref=12345
www.my-domain.com?ref=12345
(ref here is an id or something that points to the referer user in my DB) - send the link via sms / mail - when someone clicks the link he is redirect to a custom page like
www.my-domain.com/invite
www.my-domain.com/invite
- Here using my custom sign-up or even Kinde Registerlink you make the user registers himself but you'll pass an argument
postLoginRedirectURL
postLoginRedirectURL
either to your custom function or as a props on RegisterLink with my callback in which i'll add the ref URL param. So it will look like
postLoginRedirectURL="www.my-domain.com/register/callback?ref=12345"
postLoginRedirectURL="www.my-domain.com/register/callback?ref=12345"
- On the callback i'll have the logic to get check if there is a ref url param. If so then I'll attach the referer id to the referee. In the end it will let me know User B has registered with a referral link from User A (id 12345) Sorry for the late answer. Hope this helps. Don't mind asking for anything else !
Samuel Corsan
Samuel CorsanOP3mo ago
tysm 🙂
IkiTg07
IkiTg073mo ago
Hey just a quick note I forgot to say that when i redirect the user to the /invite page i also pass it the ref url param so it's more like
www.my-domain.com/invite?ref=12345
www.my-domain.com/invite?ref=12345
disamdev
disamdev3mo ago
hey I am the one who created this thread but with another account I have a doubt when I apply it In the landing to add the ?ref=id in the postLoginRedirectURL property of <LoginLink /> at the end of the link and have it work in both production and development: I would have to use KINDE_POST_LOGIN_REDIRECT_URL?ref=id, the thing is that as I do not use NEXT_PUBLIC it gives a hydration error, my question is if it is good practice to pass it to NEXT_PUBLIC that variable to be able to use it this way or how do I do it? @IkiTg07 ?
IkiTg07
IkiTg073mo ago
Hello, I don't understand why would you want to use the env var ? Is it because the url is different when in prod / dev ?
disamdev
disamdev3mo ago
exactly also, if in the future i change the redirect url for some reason
IkiTg07
IkiTg073mo ago
If that's the case i'd suggest using a NEXT_PUBLIC env then. You could use them to custom redirect for specific cases
disamdev
disamdev3mo ago
yeah but Could I change the variable KINDE_POST_LOGIN_REDIRECT_URL and put NEXT_PUBLIC in front of it and use it or would I have to create another one because then Kinde does not recognize it? @IkiTg07
IkiTg07
IkiTg073mo ago
Mmm great question. Never tried it but for the moment i'd advise to use a different variable. I'll ask the team for more details on that
disamdev
disamdev3mo ago
thanks

Did you find this page helpful?