Next.js Discord

Discord Forum

How do I make next/router not reload the entire page, similar to next/link?

Answered
Asiatic Lion posted this in #help-forum
Open in Discord
Asiatic LionOP
As articulated in the docs, next/link works via Soft Navigation, meaning components unaffected by the navigation are not re-rendered. This is cool but I've been struggling with making next/router replicate this behavior. In particular, I'm working on a form component. Default form behavior reloads the page. Next/router reloads the page. Any ideas?
Answered by Asiatic Lion
oh my god im an animal. i completely forgot that i commented out e.preventDefault() like hours ago
View full answer

4 Replies

<Link> is basically equivalent to <a … onClick={() => router.push(…)>, so just use router.push()
@joulev <Link> is basically equivalent to <a … onClick={() => router.push(…)>, so just use router.push()
Asiatic LionOP
unfortunately i've tried that already. it's still causing a full reload
Asiatic LionOP
oh my god im an animal. i completely forgot that i commented out e.preventDefault() like hours ago
Answer
It happens haha no need to be that disappointed