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>
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By 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, 2024