Meteor SSR references?

Hi everyone,
I am looking for some great examples of how to create a SSR Meteor React project with Methods/Publications.

There isnt much about this and the few things I do find are related to Apollo.

Thank you

What router are you using?

Im using react-router-dom

I have never used react because the Meteor app I inherited is nearly 7 years old ;0. So I know how to do it with Blaze. But the concepts should be similar. You need something that can render to a string or a stream. Did you look at ReactDOMServer – React (reactjs.org)

1 Like

Please Read this :

https://github.com/meteor/meteor-feature-requests/issues/420

1 Like

You might have a look at communitypackages:react-router-ssr

https://packosphere.com/communitypackages/react-router-ssr

That should get you going for any pub/sub data. Soon there will be a new release of the communitypackages:fast-render package that will enable easily using methods as the data loading method.

1 Like

react-router-ssr is expired , And it does not work properly.
Very good if fast-render is rebuilt.
Is this news definitive?

are you see this :

https://forums.meteor.com/t/fast-rendering-is-officially-obsolete-and-looking-the-new-owner/54776?u=saeeed

communitypackages:react-router-ssr is not expired. There was a time when it had an issue due to a bug in the staringatlights:inject-data package but that was recently forked to "communitypackages:inject-data` and react-router-ssr was updated to make use of the new package.

The news is definitive as I am the one doing the work to bring this to fruition.

If you are following it then thank you for following this issue as well.
This was my biggest problem with fast rendering and I have to make sure that this problem is solved in your package.

https://github.com/Meteor-Community-Packages/meteor-fast-render/issues/2

If you have tips or references on how to do it for Blaze, I’d love to see them. My application also still uses Blaze, and SSR was quite confusing, so I focused on reducing my package size with dynamic imports, and have a reasonable load speed. But would love to revisit it if there are good guides on getting it done.

FWIW, I’m also on IronRouter (This is a really old codebase, but it still runs fine and gets plenty of users).

Well my use case for SSR was doing files (icals, emails, etc). But you can certainly do pages with the same machinery. Here is how I render to a string which can then be written to a file or a stream in an iron:router response action.

A better way to do SSR with blaze in meteor than meteorhacks:SSR? - #2 by bogometer.

I also use iron:router (old app). I just define routes that only run on the server as you normally would. And then those routes use the code above. The only thing which is a PITA is the server route has no notion of who is logged in if you need that. When I require authentication, I either use meteor’s login tokens (if you don’t mind knowing internals) or create your own token collection. The token is passed by the logged in the client and grants the right to access the server route for a limited time.

An example of a route on the server side:

Router.map(function() {

    this.route('/users/report/:filename', {
        where: "server",
        action: function() {
            usersExport(this, (this.params.filename || 'glousers.csv').slice(0, -4)); // remove .csv
        }
    });

    this.route('/users/export', {
        where: "server",
        action: function() {
            usersExport(this);
        }
    });

});


And for the record, I think iron and blaze are just fine. When done properly, its bloody fast.