QwikDev/qwik

SSG not using client side navigation[๐Ÿž]

Opened this issue ยท 3 comments

Which component is affected?

Qwik City (routing)

Describe the bug

When using a server adapter (I have tested express, fastify, bun, deno) and using SSG the following happens.
When initially opening a pre generated page and clicking a link the new page is completely reloaded, even though I am using the Link from qwik-city. Client side navigation works however when I open a SSR page or navigated to the pre generated page on the client.
Checking the network tab(need to check preserve log) it seems like a js file is loaded after clicking the link but a normal navigation loading the entire page again still happens.

When using the static adapter both pages are pre generated so the bug occurs always.

Why I think this is a bug:
The documentation states: "The Link component uses the useNavigate() hook internally." (Link is generated by github)
But when using a button with the useNavigation hook to navigate, it always uses client side navigation as I expect from links.

Reproduction

https://github.com/oxydemeton/qwik-ssg-link

Steps to reproduce

In the reproduction repo:

$ npm install
$ npm run build.client
$ npm run build.server.fastify
$ npm run serve.fastify
  1. Open the website in a browser. (States it is server rendered)
  2. Navigate to the second page using the link. (States it is server rendered, even though I expect client)
  3. Navigate back to the root page. (State it is client rendered)
  4. Navigate to the second page.(Now it is client rendered.)

The same can be observed in the network tab when preserving logs. A new page is loaded and when disableing preserve logs the previos ones are deleted since a new page is loaded during step 2 where the bug occurs.

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (16) x64 AMD Ryzen 7 3700X 8-Core Processor
    Memory: 21.56 GB / 31.91 GB
  Binaries:
    Node: 22.3.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.2.4 - C:\Program Files\nodejs\npm.CMD
    pnpm: 7.30.3 - ~\AppData\Local\pnpm\pnpm.EXE
    bun: 1.1.21 - ~\.bun\bin\bun.EXE
  Browsers:
    Edge: Chromium (127.0.2651.8)
    Internet Explorer: 11.0.22621.3527

Additional Information

No response

Hello, I am working on this right now.

"Client side navigation works however when I open a SSR page or navigated to the pre generated page on the client." @oxydemeton I don't understand this sentence.

I meant that a single page can work when client side rendered( e.g. when navigated to it on the client) even though the same can have the bug when loaded from the server.
In my example:
The links on the root page works when the root page is rendered on the client and not the pre-generated html is used.