How do we pre-fetch the page using next/router . Tried some way but none worked. #15431
-
I have seen a feature available with By referring to the example available at documentation, I've came up with following piece of code try {
await router.prefetch(
'/[organization]/reports/[id]/view',
`/${organization}/reports/${reportId}/view`,
);
// navigate to page
router.push(`/${organization}/reports/${reportId}/view`); // <------------------- not worked
router.push( // <----------------------- not worked
'/[organization]/reports/[id]/view',
`/${organization}/reports/${reportId}/view`
);
} catch (err) {
console.log('Pre-fetch error ', err);
} In the above snippet neither of them worked!! Am i doing anthing wrong |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
Hi @ananth-minions. Aside from that, in your example the second router.push(
'/[organization]/reports/[id]/view',
`/${organization}/reports/${reportId}/view`
); when you say they didn't work, what didn't work about them? Did the page not transition? Also do you happen to have a repository with some of the code you could share? |
Beta Was this translation helpful? Give feedback.
Hi @ananth-minions.
Aside from that, in your example the second
.push
attempt should've worked:when you say they didn't work, what didn't work about them? Did the page not transition? Also do you happen to have a repository with some of the code you could share?