nextjs
Hello
When working with nextjs which is the best option to use for redirecting : refine's useGo() or nextjs's useRouter?
When working with nextjs which is the best option to use for redirecting : refine's useGo() or nextjs's useRouter?
next.config.js: For static redirects based on path matching, headers, cookies, or query parameters.NextResponse.redirect for dynamic redirects.getServerSideProps and getStaticProps: For server-side redirects.getServerSideProps:useGo()useGo() hook is useful for client-side navigation within a Refine application. It is particularly handy when you need to navigate between resources defined in your Refine app.useGo():useGo() for client-side navigation within a Refine application, especially when navigating between resources.next.config.jsNextResponse.redirectgetServerSidePropsgetServerSidePropsgetStaticPropsuseGo()useGo()useGo()useGo()export const getServerSideProps = async ({ res }) => {
return {
redirect: {
destination: "/new-url",
permanent: false,
},
};
};import { useGo } from "@refinedev/core";
const ProductShow = () => {
const go = useGo();
return (
<button
onClick={() => {
go({ to: { resource: "products", action: "list" } });
}}
>
Go to Products list
</button>
);
};