App reviews, troubleshooting, and recommendations
Hello.
I want to use Navigation in Next.js,
But There are no contents React Hooks or React Components in docs(https://shopify.dev/docs/api/app-bridge-library/apis/navigation )
unlike previous-version docs(https://shopify.dev/docs/api/app-bridge/previous-versions/actions/navigation )
Only Remix version of the guide exists in that document.
(I don't have any plan using Remix.)
How to Migrate useNavigate in App Bridge React 4.x.x using Next.js?
Thank you.
Hi @camerafi-dev,
I don't use Next.js but ended up here while looking for a solution for vanilla react.
There is a hook in the react-router-dom library. So this works for me:
import { Link } from "@shopify/polaris";
import { useNavigate } from "react-router-dom";
const navigate = useNavigate();
<Link onClick={() => navigate(`/page`)}>Page</Link>
import { Link } from "@shopify/polaris";
import { useRouter } from 'next/navigation'
const router = useRouter();
<Link onClick={() => router.push(`/page`)}>Page</Link>
By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024Thanks to everyone who participated in our AMA with 2H Media: Marketing Your Shopify St...
By Jacqui Sep 6, 2024