New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Server-side rendering blockers #40
Comments
Thanks for bringing it up! There are a few more things we need to do to explicitly support SSR as well. |
@stubailo I've solved 90% of the problems around SSR. HTTP response header is not an issue. This involve one hack which I used for fast-render. I know @glasser is working on a proper fix for that. So, I'd like talk about this and what are things still in the queue. It's better if you could do an open discussion. |
Can we do the open discussion here? Seems as good a place as any. What are the 10% of remaining problems? |
Sure :) |
Here's what I completed. (But needs heavy testing)
Here's a working version based on that. All the pages in this side load from SSR. (pages are on the db)
So, these are working pretty well and needs more testing. Here's the missing 10% Now this SSR is for basically for search engines and bots. For real users (loggedIn users), SSR won't matter and we should not do it. Because it's super expensive in CPU wise. But for them, we can just use FastRender. Because that's something pretty efficient. But there's a catch. In order to identify subscriptions, we need to run components on the server. So, not way to get around with it. So, now I'm thinking on a system to guess subscriptions based on routes. It needs to render components few times. Then, it'll learn subscriptions for a given route. Then, in the next time it can do fast-rendering. Here's what we need from MDG Here's I used some safe hacks (used for fast-render from the beginning) to send HTML. But I think MDG is working on a way to do it. Then, we also need a way to customize the response header and status as well. |
Wait, I thought you just said we don't need response headers from MDG. So to summarize you want:
Doesn't seem like much! Is that all? What are additional things you would need to reduce the amount of hacks? |
I didn't get this properly. We need to a way to tell to change response headers for the current request. Then, we can do server side redirects and other stuff. So, best idea is to add some APIs to the nodeJS Yeah! I told you it's not much :) Oh. I forgot another thing. There is another hack. (not a hack a bit kind of overriding thing). But, I think for now it's good since we are pretty not sure about how SSR Context is going to change and so on. |
We can do SSR for Blaze as well. So, make templates available on the server as well. It was there earlier. But, removed it to reduce the bundle size. Bring it back :) |
One blocker I have with react-router SSR is an error that gets thrown when rendering to a string. From what I can gather this vague error is common when you forget to use module.exports so i'm thinking it's an npm / browserfy / exposify issue. I'll try to dig into this later next week. https://github.com/AdamBrodzinski/meteor-react-ssr-spike/issues/1
|
@arunoda You might find this interesting... How Netflix does their React serverside rendering. basically they're rendering a portion of the page with less data then rendering the rest on the client. This might mitigate some of the rendering CPU issues? http://techblog.netflix.com/2015/08/making-netflixcom-faster.html |
For those following this issue, server-rendering is working perfectly fine with the Meteor package react-router-ssr and the ReactMeteorData mixin. |
How are people using this and getting it to work correctly? I'm getting the same error as @AdamBrodzinski pointed out, trying to use the reactrouter:react-router and reactrouter:react-router-ssr packages. |
@john-osullivan What are you trying to accomplish? With |
I've tried at least three different configurations: (1) installing react-router via npm, (2) using reactrouter:react-router alone, and (3) installing reactrouter:react-router-ssr and using that, none have worked correctly yet. There have been different errors in each one, so I'm unfortunately having a different issue now. Using the third approach, where I uninstalled reactrouter:react-router as well as reactrouter:react-router-ssr, then reinstalled reactrouter:react-router-ssr, I'm currently getting a bug saying React isn't defined. The router is stored in a folder running on both the server and client. Externalify is installed and react is specified within EDIT:
|
Can you post your code or a repo I can see your project? Bte you shouldn't use browserify to get react or react-router. There is packages on meteor for that that arr easier to setup. |
Sure, here it is: https://github.com/john-osullivan/grup/ . The way it's currently set up, I'm not getting React myself -- I'm using Meteor's react package, and the reactrouter:react-router-ssr package to get ReactRouter. For additional context, I'm running on a Windows 10 machine. |
@john-osullivan I seems like if you update your project to Meteor 1.2, it is wroking perfectly. I'll add a version restriction on the package because I have no intention supporting Meteor 1.1. Remove npm-container from your project, |
Thanks for the help, @eXon ! Updating to Meteor 1.2 did get rid of that error for me, although the update process recreated npm-container when it found that I had cosmos:browserify as a dependency. There must be some weirdness between our separate configurations, because I'm getting:
Do I need to be installing and configuring exposify myself somewhere? Thanks for the help here -- I'd love to be using your code, just trying to figure out what I'm setting up incorrectly. EDIT: Examining the full stack trace, the problem definitely seems to be in how this tool plays with cosmos:browserify:
My browserify file isn't being used to load reactrouter, so that's confusing. All it does is import classnames, which shouldn't conflict. Removing the package from my list of dependencies also didn't change anything, I get the same error. |
Hey @eXon , I just updated to version 0.2.5 of react-router-ssr and everything seems to be working as intended! No more weird browserify bugs. Still having some issues getting components to actually render, as what's being passed in seems to be an instance of ReactClass rather than the component I tried to define using React.createClass(), but that seems like an issue with how I'm doing things rather than with the library. Thanks for the help! EDIT: To save myself the trouble of debugging how to get meteor-react-boilerplate to play nice with react-router-ssr, I'm just going to switch over to your kickstart repo! Thanks for making such a full-featured boilerplate repo, it makes things much easier for me as a Meteor beginner. |
I'm closing this just because it's too old. We can open new issues for items that are still valid. |
Since it looks like SSR is now doable, it looks like this issue and this issue might be closer to getting properly addressed at the core level for SEO's sake?
The text was updated successfully, but these errors were encountered: