Next.js 14 Tutorial - 21 - Navigating Programmatically
Вставка
- Опубліковано 20 лис 2023
- 📘 Frontend Interview Course - learn.codevolution.dev/
💖 Support UPI - support.codevolution.dev/
💖 Support Paypal - www.paypal.me/Codevolution
💾 Github - github.com/gopinav
📱 Follow Codevolution
+ Twitter - / codevolutionweb
+ Facebook - / codevolutionweb
📫 Business - codevolution.business@gmail.com
Next.js 14
Next.js Tutorial
Next.js 14 Tutorial
Next.js Tutorial for Beginners
Navigating Programmatically
Next.js Navigating Programmatically
This tutorial is so helpful. Thank you for being you.
🤝♥️thank you for the content vishuas
This is awesome
[memo] import { useRouter } from "next/navigation";
loved it, new videos pleaseeeeeee
awesome bro
If in case anyone facing the issue
Unhandled Runtime Error
Error: NextRouter was not mounted.
Please check the import it should be import { useRouter } from "next/navigation"
thanks bro, hope you have a good day
Please make video on setting up styled component with next js csr and ssr
Back!!
GoodJob!
Thanks for your awesome videos! Question here: why couldn't we just wrap the button in a Link tag and identify the desired href?
You can WHEN there's only one direction. Like going from Home to About using navbar. [You are certain that there's only one point/route to reach to]
BUT when you encounter going to certain route out of many routes based on certain condition, You may wanna use "useRouter" hook.
Example:
-> Suppose you have an order-product, If the transaction/ordering was successful. You may wanna route to "/{productId}/success" and if it's unsuccessful, you may wanna route to "/{productId}/failed".
@@SuryaBahadurBasnet thank you so much for the detailed response! Makes perfect sense and thanks to you I’ve learnt one additional thing today:)
A lot of warnings in the console and here it runs only if I add "use client"; at the top. But is it really safe to make this page visible to the client?
i have a question but we have Link component , why whe use useRouter to handle routing
Because we already learnt about link tag, now it's time to learn routing programmatically 😅
It's because you can programmatically route to anywhere, giving you more control. So you can add it to functions if you want.
Maybe after an animation finishes then the app will go back to home page on its own, etc...
Sir, If I redirect the login page from another app and use a router.back() after login it redirects to that app but it should redirect to the homepage of our app. How can I fix this?
when i'm using npm run build, it's throwing an error "Error: React Hook "useRouter" is called in function "orderProduct" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter. React Hook names must start with the word "use"."
is there a possible fix for that?
The solution is actually within your comment written it self
So this will be a client side rendered page? @Codevolution
yes
🙏👍
sir please send notes all next.js playlist Asap
When I am importing useRouter, the auto suggestion shows me two hooks. One from next/navigation and the other from next/router. What's the difference and why do we use next/navigation?
next/navigation is a newly and advanced packages introduced in a next js 13
while next/router is old version of next js and mainly purpose for routing within the pages folder of next js application
next/router would crash my app as it seems like a previous version. next/navigation works fine!
When will this series end ? How many videos still pending ?
78 videos
Router.push? Before watching i am commenting
correct
depends on how you name your const variable. However you should use camelCase for better syntax. so router.push, not Router.push.