Wonderful, thank you sharing this, love the cognito server actions, will help alot. Tutorial request: would you mind creating a tutorial on turbo repo with shared shadcn components library between two nextjs projects, there are not enough information about that, would really appreciate that 🙏
Thank you for the suggestion. Frankly speaking, I'm thinking about pivoting more into AWS. Doing tutorial on turbo repo is definitely a good idea as well.
Envs are user pool and client IDs. They are not secrets and can be stored on the frontend. Cognito's app client also has a secret. That secret should be stored securely on the backend.
I think you can access it the same way we access it in the middleware const user = await authenticatedUser({ request, response });, but instead of request, response object you can put a cookie object as a context. On server side you can get cookies using Next cookies function.
You are welcome! There are different branches in the repository corresponding to the parts of the video. The full implementation will be here: github.com/alexrusin/nextjs-cognito-auth/tree/5-reset-password-end
You can use Cognito hosted UI, but not for this. Amplify package is used to help host your own UI rather than use Cognito's. Also, the flow will be a little bit different.
Hi Alex, really comprehensive video. I have an issue, even after setting autoSignIn as true after confirmSignUp is called and next step is COMPLETE_AUTO_SIGN_IN. when I call authoSignIn(). i get this error "The autoSignIn flow has not started, or has been cancelled/completed."
Usually navigation is rendered on the client side. I didn't give it a second thought, frankly speaking. You can try generating it server side. However, you will have to get authenticated user server side as well. useAuthUser hook won't work.
Fantastic! You saved my one week in only one hour. Gracious 🎉
Great to hear! I'm glad I could help.
Wonderful, thank you sharing this, love the cognito server actions, will help alot.
Tutorial request: would you mind creating a tutorial on turbo repo with shared shadcn components library between two nextjs projects, there are not enough information about that, would really appreciate that 🙏
Thank you for the suggestion. Frankly speaking, I'm thinking about pivoting more into AWS. Doing tutorial on turbo repo is definitely a good idea as well.
Could you help me understand how this is safe to use on the front end? Since it’s a client component, wouldn’t the envs be visible on the front end?
Envs are user pool and client IDs. They are not secrets and can be stored on the frontend. Cognito's app client also has a secret. That secret should be stored securely on the backend.
Can you explain how to access the user in a server component, I cannot find that anywhere online :/
I think you can access it the same way we access it in the middleware const user = await authenticatedUser({ request, response });, but instead of request, response object you can put a cookie object as a context. On server side you can get cookies using Next cookies function.
Thank you! One quick question, where is the full implementation repository? I only found the base project
You are welcome! There are different branches in the repository corresponding to the parts of the video. The full implementation will be here: github.com/alexrusin/nextjs-cognito-auth/tree/5-reset-password-end
would it be possible to use cognitos self hosted UI for this?
You can use Cognito hosted UI, but not for this. Amplify package is used to help host your own UI rather than use Cognito's. Also, the flow will be a little bit different.
Hi Alex, really comprehensive video. I have an issue, even after setting autoSignIn as true after confirmSignUp is called and next step is COMPLETE_AUTO_SIGN_IN. when I call authoSignIn(). i get this error "The autoSignIn flow has not started, or has been cancelled/completed."
Thank you. That is strange. I suggest checking your Cognito setup in AWS.
i can receive the current auth user on my client side but not on the server ,the user object returns null values ,I don't know what im doing wrong
Try cloning the reference project from github and see if it works for you. Then you can compare it to your code.
Great setup and thank you! however how to set up the httpOnly to true ?
You are welcome!. Sorry, I'm not sure what you are referring to when saying "set up the httpOnly true"
Awesome 🤙
Thanks 🤗
Why did you make nav-links.tsx client rendered. Couldn't that have been done on the server?
Usually navigation is rendered on the client side. I didn't give it a second thought, frankly speaking. You can try generating it server side. However, you will have to get authenticated user server side as well. useAuthUser hook won't work.