penumbra-zone / dex-explorer

Web app for visualization the state of the Penumbra DEX
Apache License 2.0
10 stars 1 forks source link

feat: #143: experimentally request summary data on server #145

Open VanishMax opened 6 days ago

VanishMax commented 6 days ago

Fixes #143

⚠️ EXPERIMENTAL

This is a draft of moving data request on server. So far it looks like too much work. All of the changed code only moves the summary request to server components. This is how it works:

  1. When a user types the URL, the browser then sends the URL to our server
  2. The server tries to pre-render the HTML string of the server components
  3. It makes the request to the summary
  4. The result of this request is used to render the html without isLoading in react query. If user has JavaScript disabled in their browser, it would render the html of the summary block normally, without any skeleton loaders
  5. The serialized data of the request is also sent to the browser via react-query's HydrationBoundary component. See the screenshot below – it shows how react-query populates the html with the server-side data that is then taken by the client
  6. When the client component Summary tries to useQuery, it takes the data from the server instead of making the new request

Now, what do you think of this approach? Should we continue investigating the best pattern of server-side request?

Screenshot 2024-11-21 at 16 26 13