Meteor SSR complete example


Hello! couldn’t manage to get working SSR with the available documentation, any examples appreciate it.

Currently I’m not able to make SSR render on the server.

import { Meteor } from ‘meteor/meteor’;
import { Template } from ‘meteor/templating’;
import { ReactiveVar } from ‘meteor/reactive-var’;
import {SSR} from ‘meteor/meteorhacks:ssr’;
import ‘./main.html’;
if (Meteor.isServer) {
SSR.compileTemplate(‘body’, Assets.getText(‘main.html’));

    getConfirmationURL: function() {
        return this.url;
//SSR.compileTemplate('body', Assets.getText('main.html'));


import { Meteor } from 'meteor/meteor';
import {SSR , Template } from 'meteor/meteorhacks:ssr';

Meteor.startup(() => {
  // code to run on server at startup
var html = SSR.render("body", {username: "arunoda"});

Thank you in advance.


To be able to run method both from client and server:{to, from, subject, doc}, function (error) {
  if (error) {
    console.error('sendEmail error:', error.message);
    return false;

I have this code structure:


import '/imports/startup/server';
import '/imports/startup/both';


import '/imports/startup/client';
import '/imports/startup/both';


import '/imports/api/email_methods';


import { ValidatedMethod } from 'meteor/mdg:validated-method';
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
import { Email } from 'meteor/email';
import { SSR, Template } from 'meteor/meteorhacks:ssr';

export const sendEmail = new ValidatedMethod({
  name: 'sendEmail',
  validate: new SimpleSchema({
    to: {type: String, regEx: SimpleSchema.RegEx.Email},
    from: {type: String, regEx: SimpleSchema.RegEx.Email},
    subject: {type: String},
    doc: {type: Object, blackbox: true}
  run({to, from, subject, doc}) {
    if (Meteor.isServer) {
      SSR.compileTemplate('htmlEmail', Assets.getText('templates/email.html'));

        numeral(num) {
          if (num) { return numeral(num).format(); }

      Email.send({to, from, subject, html: SSR.render('htmlEmail', doc)});


Thank you zzs! will give it a try!