Redirect to register instead of login?
I have "Start free trial" button on my page. It redirects to /checkout and /checkout is protected by the middleware. But the problem is it redirects user to login instead of register. How can I make it redirect to register? I use Next.js SDK
24 Replies
Hey @Konrad,
Thanks for reaching out.
For the Next.js SDK, you can use the
Sign up and sign in To implement the registration functionality, you can use the
RegisterLink
component to redirect users to the registration page instead of the login page.Sign up and sign in To implement the registration functionality, you can use the
RegisterLink
component provided by the SDK. Here's how you can use it:
You can customize the redirect URL after registration by using the postLoginRedirectURL
prop:
This will redirect the user to the /checkout
page after they have completed the registration process.
If you want to implement this programmatically instead of using the component, you can use the register
function:
Remember to update your middleware to allow access to the registration page. You might need to adjust your middleware configuration to ensure it doesn't redirect unauthenticated users away from the registration process.Getting back to this:
-
<RegisterLink postLoginRedirectURL="/checkout">Sign up</RegisterLink>
- the problem is after user logs in and I press it again then the user is still redirected to register page... so this solution won't work and having if
everywhere would be far from elegantHey @Konrad,
Are you able to record the issue where "user logs in and I press it again then the user is still redirected to register page."?
This will help my team replicate the issue and troubleshoot the issue easier.
I mean you can easily test it in a demo app. Just show RegisterLink unconditionally with postLoginRedirect and click it after login
Let me look into this and get back to you tomorrow.
Okay thank you
Hey @Konrad,
I am struggling to reproduce this.
When I click the
<RegisterLink
after I am logged in, I am redirected to the postLoginRedirectURL
.
I am sure I have not setup my app the same way you did.
So if you could send a recording or a code snippet of where you experience this issue, that would help my team and I reproduce and troubleshoot this issue.are you using
import {RegisterLink} from "@kinde-oss/kinde-auth-nextjs/components";
![No description](https://cdn.answeroverflow.com/1279809569048232058/image.png)
It has to be full URL i see, but even with a full url it doesnt work... I stay at register page
i use custom domain too
I will just create my own wrapper component I think because this is getting tiresome
also
This doesn't work.
register
is not part of nextjs specific package
im also using latest version (2.3.8)yes I am. I was still unable to reproduce your issue.
register
is part of the React SDK method.
Whereas RegisterLink
is part of the NextJS SDK.Hey @Konrad,
I think the best next step would be to post an
GitHub issue
on our NextJS SDK GitHub repo that outlines the issue you are experiencing.
My NextJS expert team mate constantly looks at the issues on the repo and addresses them.
Please include as much information as possible on the GitHub issue
so my team mate can reproduce the issue and fix it.GitHub
GitHub - kinde-oss/kinde-auth-nextjs: Kinde NextJS SDK - authentica...
Kinde NextJS SDK - authentication for server rendered apps - kinde-oss/kinde-auth-nextjs
Can react sdk coexist with nextjs sdk in the same project?
It can, but I am wondering why you would want to do that?
Are you able to elaborate on what you are trying to do?
Just simple thing I described. I Think i will just copy middleware and modify it to my needs
From kinde sdk repo
I had a person who clicked on “try for free” but he was redirected to login
And called me why it doesn’t work
So I think UX is not good enough
And „don’t have an account „ is not easy to see. I need to see how big sites like YouTube do it