Next.js Discord

Discord Forum

prefetch doesn't seems to work

Unanswered
AM posted this in #help-forum
Open in Discord
AMOP
I have 2 scenarios in 1 it works out of the box on another - more simplier it does not:

so i got 2 routes
/[filter]
/details/[id]

on /details/[id] i can see prefetches but on /[filter] nothing happens

prefetch on details:

const { prefetch, push } = useRouter();

  const castDetailsLink = `${APP_LINKS.CASTS}details/${cast.hash}`;

  useEffect(() => {
    prefetch(castDetailsLink);
  }, [prefetch, castDetailsLink]);


prefetch on filters:

 const airdropLink = `${APP_LINKS.CASTS}${CASTS_FILTERS.AIRDROP}`;
  const degenLink = `${APP_LINKS.CASTS}${CASTS_FILTERS.DEGEN}`;
  const gamesLink = `${APP_LINKS.CASTS}${CASTS_FILTERS.GAMES}`;
  const mintsLink = `${APP_LINKS.CASTS}${CASTS_FILTERS.MINTS}`;

  useEffect(() => {
    prefetch(airdropLink);
    prefetch(degenLink);
    prefetch(gamesLink);
    prefetch(mintsLink);
  }, [prefetch, airdropLink]);


like filters are known a head of time and i want to fetch the data for em

i've tried filter && details convert them to client/server vice versa eeverything - one is being prefetch and another do not, any ideas why might prevent prefetching?

0 Replies