#Solid Start - routeData

12 messages · Page 1 of 1 (latest)

sick swan
#

Hello everyone! 🙂

I read the solid.js and solid start docs today and Im kind loving the simplicity. Really thinking in building a portfolio with it (I currently work with Nuxt 2 + GraphQL but I really love learning new things and finding out if I could be missing out or be doing things better).

The question is actually very simple teorically but I did not find info anywhere.. When using routeData with Solid Start the data will be fetched both in client and server, how can I avoid making 2 requests and send the serialized result of the query in the server to the client and not messing up the hydration?

Thanks in advance!

neat ember
#

I think serverRouteData is what you're looking for

#

or rather createServerData$

sick swan
#

Even so, if I use createServerData$ solid does an RPC request to the server on the client to fetch the data again correct?

neat ember
#

let me check...

#

Ok so it seems routeData runs both on the server and on the client on initial request/render, but both createRouteData and createServerData$ only runs on the server

sick swan
#

So solid has a mecanism wrapped inside createRouteData and createServerData$ that serializes the data to the client. So when we run the routeData in the client Solid has a store somewhere with the server data and retrieves the results from it?

neat ember
#

seems so, the function inside createRouteData and createServerData$ only runs once on initial render

floral adder
#

What's the difference of createRouteData and createServerData?
@neat ember

neat ember
#

whether the data fetching happens on the client or server on client side navigation

tardy crow
#

createRouteData should be preferred in most cases

sick swan
#

I will take a look in the source code. Still I think it should be explicit that solid does serialize the data to the client