The fast render package is a bit of a hack I think.
With SSR, the data can be injected and used to hydrate the client, which I think is cleaner than the subscription highjacking that this package does.
The fast render package is a bit of a hack I think.
With SSR, the data can be injected and used to hydrate the client, which I think is cleaner than the subscription highjacking that this package does.
If you render a list with classic meteor pub sub, you subscribe to the data set and iterate over it. If you do this with server sider rendering you get multiple problems:
At least some of these problems are solved (yes hacky) in fast-render. The first can be solved with more discipline, by always defining precise selectors for Meteor.Collectio on the client (this is a common flaw of meteor pub/sub).
@alawi fast render DOES exactly extract the subscription data and hydrate. For this to work, it has to monkey-patch the pub/sub mechanism.
React is along way off - and there are solutions available today that we just need to polish.
For SSR in Meteor with React, we currently need:
dynamic-imports
and server-render
npdev:react-loadable
eventually lazy
might be used, but I think there will always need to be integration at some level. I maintain this, but it could probably use a design pass to make it easier to use.staringatlights:fast-render
(or similar) - This adds Meteor.subscribe
and the accounts APIs to the server, and does the capture work, etc.For fast-render, there may be easier ways to implement the same behavior using a normal React Context Provider, which would b e easier to maintain (while retaining the work to sort of polyfill subscribe and accounts on the server). Iād actually love to do that work, but I have a full time job these daysā¦ Iād be happy to share some thoughts on how to approach that if someone wants to take up an implementation effort. On the other hand, it might make sense just to try and maintain fast-render - but as part of core (it can be used by more than just react).
I believe both of these components should be in Meteor core.
Instead of focusing on subscription, better if we focus on how to properly hydrate data from methods.
The normal use case of SSR is for SEO. And therefore, the pages normally used for this are pages accessible to non-logged-in users. And most of these pages use methods. It is rare that guest pages will require pub-sub and also SEO
Yes, that is the use case for me. I hydrate the landing page by injecting the data with the SSR. I didnāt have a case where Iāve pub/sub at the landing page.
Hydration from methods can be done relatively easily - but it needs the accounts support server side provided by fast-render
. That support should at the very least be in core.
Yes, I only borrowed the account initiation during SSR.
Iāve that code extracted in a package here https://github.com/aliogaili/ssr-helper.
In addition it has helperer methods to inject/retrieve data during SSR.
Seems that answer the question on what must be in the core. @alawi has already the required changes which seems perfect as a PR for the server-render package
Then the front-end-library specific handling can use these helper functions
Maybe these additional packages:
server-render-accounts
(gliogaili:ssr-helper)server-render-pubsub
- contains tools to enable Meteor.subscribe
in server-render, and capture/hydrate that data. This can either be done like it is in fast-render
by adding a step in front of server-render
's onPageLoad, or it could expose tools to do it properly in your chosen front end stack.Iām honestly not sure how staringatlights:fast-render
even integrates with routing. It seems to work, but how?
Or just copy all of staringatlights:fast-render
to a core fast-render
packageā¦
I do not think leaving pub / sub in ssr is the right thing to do.
Using methods for data is just clearing the face of the issue.
That is why I say that any external package only erases the problem and is difficult to bypass.
The separate problem must be solved inside the kernel
Hello everyone again.
We are talking seriously about ssr in metoer.
I invite all those who are concerned about it