How can we pass the data from one route to another route programatically using router.push api of useRouter() from next/navigation
?
Also how can we perform url masking in router.push api from next/navigation
which was possible in router.push from next/router
?
thess are actually two questions.
'use client'
import { useRouter } from 'next/navigation'
export default function Page() {
const router = useRouter()
return (
<button type="button" onClick={() => router.push('/dashboard?prop=value')}>
Dashboard
</button>
)
}
asPath has been removed because the concept of as has been removed from the new router. Not recommended to use as
.