Next.js Discord

Discord Forum

how to use router.prefetch

Unanswered
SID posted this in #help-forum
Open in Discord
Avatar
SIDOP
I have a dynamic route for users, i.e., /user/[id]. How can I prefetch JavaScript for this page while someone is filling out a form to create a user, given that the id is set from the backend?

Can I use something like router.prefetch("/users/[user-id]") Is this valid, with [user-id] instead of the actual ID? I tried this, but I'm getting [d]?_rsc=19lgi in the response, which doesn’t seem valid.

0 Replies