0

I have a NextJS app that incorporates shared components from another repo which is built into a package via vite.

next/link instances inside the package do not prefetch when run inside the next app. The app is running in production mode, and I've verified prefetching works properly when I put the same link in the next app proper.

I've also got the package included in the transpilePackages option of next.config.js.

How can I get the next/link instances inside the shared package to prefetch as expected?

2
  • A code example might help. But from what i can see you might solve this by injecting the Link from your app to the components mentioned. Commented Oct 2, 2024 at 1:57
  • That's what I ended up doing as a workaround, but I'm curious if there is a way to get next/link to work as expected when used in a packaged library running in a nextjs app. If not, and there is sufficient proof, I'm cool with that too. Commented Oct 2, 2024 at 2:41

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.