#NextRouter was not mounted. Trying to redirect onApprove from PayPal

10 messages · Page 1 of 1 (latest)

pale knoll
#

I want to redirect users to "success/[id]" after a successful PayPal payment using dynamic links. The id, which corresponds to the orderId from PayPal, should replace the placeholder. For instance, it should look like "success/orderid?=skdaaisjda". I also need to store this data locally. However, when attempting this, I encounter an error:

Error: NextRouter was not mounted. For more information, refer to https://nextjs.org/docs/messages/next-router-not-mounted.

This issue arises in my code at line 84 in the file components\Cart.tsx.

https://github.com/yoboywhat/Paypal-onApprove-Redirect-Issue-21-02-2024-/tree/main

GitHub

Contribute to yoboywhat/Paypal-onApprove-Redirect-Issue-21-02-2024- development by creating an account on GitHub.

full bobcatBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

vague dune
#

If you are using app router, make sure you import useRouter from “next/navigation” and NOT from “next/router”

pale knoll
#

i should try pushing the route directly on onApprove

#

wait no, but otherwise I cant take order id

#

works now

full bobcatBOT
#
✅ Success!

This question has been marked as answered! If you have any other questions, feel free to create another post

Jump to answer