How to pass data from one page to another page while redirecting from getServersidePros

export const getServerSideProps = async ({ params, query, req, res }: any) => {return {redirect: {permanent: false,destination: redirectionPath,
message: 'Hello',
},};};
npm i cookies

export const getServerSideProps = async ({ params, query, req, res }: any) => {
const cookies = new Cookies(req, res);const redirectionPath = `/same-page?eventId=${differentId}`;const responseMessage = "Hello second page";cookies.set('message', responseMessage, {httpOnly: true,});return {redirect: {permanent: false,destination: redirectionPath,},};};
Second pageexport const getServerSideProps = async ({ params, query, req, res }: any) => {const cookies = new Cookies(req, res);const message = cookies.get('message');// use this message to perform some operation// let's say you want to delete this after one use, means that after second page loads one the data should be removed and on reload we should not get the message from cookies.// code to remove the data from cookies, and this will make sure after first load your message is removed from the cookiesif (message) {
// this will remove the property from the cookies
cookies.set('message');}};

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How To Use Puppeteer With Jest & TypeScript

Hello Le Monde!

Highest Product of Three

Useful g

Share Code Between React Native and React.js

how to use mobx with create-react-app without run eject

mobx logo

Velo by Wix: Side effect wix-data saving methods

A Complete Guide about Redux with Redux Toolkit

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Rahul Singh

Rahul Singh

More from Medium

How to build an inclusive work environment

Aagje Reynders, inclusion blog

How To Use Nextjs & Graphql

What is Next.JS? How to understand it better? Understand it from the history of web development

## Intended audience