qwik icon indicating copy to clipboard operation
qwik copied to clipboard

[📖] useServerData (in v2)

Open n9 opened this issue 4 months ago • 1 comments

Suggestion

The documentation for useServerData is currently empty.

@manucorporat mentions in https://github.com/QwikDev/qwik/issues/4506#issuecomment-1597801559:

it's a very low level API, that most developers should never have to use

Should it be mentioned in the docs?

More points:

  • It's not clear in what contexts useServerData should work. Is it supported in the routeLoader$, for example?
  • What is the recommended (high level) alternative for a global server context accessible in routeLoader$, onStaticGenerate, ... ?

n9 avatar Sep 15 '25 15:09 n9

so it's used during SSR to access data that is passed to the render function. At any other point in time it returns nothing. Any data that needs to exist in the client needs to be copied into contexts etc.

for the other cases, just use module scoped data or the requestEv.sharedMap

wmertens avatar Sep 15 '25 15:09 wmertens