Topy
Topy12mo ago

Best way to pass backend data to SSR rendered view?

Looking for the "proper" way to pass data to an SSR rendered view. My first idea is setting custom properties on the window object. Is there any standard? I use Oak as a backend I know frameworks such as Express have a render method that can do that, but I don't know what it's doing under the hood. Oak does have a context.state object that, according to the docs should be able to send data to the frontend view, but I cannot find the data on the frontend. Whether it be in the http response
4 Replies
marvinh.
marvinh.12mo ago
The browser receives the HTML (if any) send by oak. Any data you want to share needs to be in that HTML
Topy
Topy12mo ago
Of course I know that. I wonder what's the proper way to store the data
Kevin Whinnery
Kevin Whinnery11mo ago
I think you might want to look at using this view engine library with Oak - IDK if Oak actually has a feature like the render function of Express: https://deno.land/x/view_engine@v10.6.0
Kevin Whinnery
Kevin Whinnery11mo ago
No description