Next.js Discord

Discord Forum

How to Pass data from one component to another component in Next js 14 next/navigaiton

Unanswered
Little Egret posted this in #help-forum
Open in Discord
Little EgretOP
import { useRouter } from "next/navigation";


const router = useRouter();
:sweating:
const handleData=()=>{

router.push('/TransactionDetails',{
data:{
network: fromDetails.network,
wallet: fromDetails.wallet,
asset: fromDetails.asset,
address: fromDetails.address,
amount: fromDetails.amount,
}
});
}

how can i get data in Transaction detail page

2 Replies

You need to put those data into a shared state eg a React context in the layout, or sessionStorage/cookies
ideally you'd want to store the transaction in the db and retrieve it from there on the other page