Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Pass sensitive data to Nextjs Link component

I have a question about Link component from ‘next-Link ’
What should I do if I want pass a sensitive data like a category_id for example, how can I pass it securely to be used in getServerSideProps() function
I don’t want want to use query string.

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

If you want to hide data from URL you can use the as property of Next Link :

<Link
  href={{
    pathname: "/myUrl",
    query: { id: "1111" },
  }}
  as="/myUrl"
>
  Go to Page
</Link>;

the url will be : http://localhost:3000/myUrl

but you still can access data :

import { useRouter } from "next/router";
//..
const router = useRouter();
console.log(router.query.id);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading