nuxt-swc
nuxt-swc copied to clipboard
`fetch` doesn't work on route change?
Hey! I'm glad to see an SWC module for Nuxt.js, I didn't expect it to see this fast but I wanted to try it out, and I guess I found an issue. I had nuxt-vite (which doesn't work for actual builds) and typescript-build module in my nuxt.config, I didn't disable nuxt-vite because it's already disabled for builds but I disabled typescript-build. Everything worked great, it was almost 3x faster... But I think it have issues with Nuxt's fetch hook on route changes. Here's my repository (I tried creating a Code Sandbox template but it didn't like my TypeScript interfaces).
Steps to reproduce
- Have at least 2 different routes.
- Make sure you use
fetch()in one of these routes. - Fetch something in the target route.
- Enter the route that you don't fetch anything and then move to the route you do the fetching.
- You'll see nothing, it doesn't fetch it.
- Reload the page and you'll see it fetches successfully.
P.S. This happened when I tried to view a blog post (on a statically generated website, using @nuxt/content) and in the route, I fetch data from Firebase. I reloaded the page I fetch data from Firebase, and it worked, but when I reloaded the content page, it failed to load the document.
What is causing this?
Hi @eggsy and thank you fir your feedback.
A reproduction should be minimal so we can easily see what's causing the issue.
Actually with SSG, the fetch and asyncData are mocked and not called anymore so I am not sure if this is related to SWC module.