Meteor server side render config?

I’ve been researching “Meteor” for 1 month and this is my website http://bgirl.cf. But after I deployed to the server I found it too slow for a website and I continued to learn SSR and I followed this tutorial Chris Visser | How to set up Meteor & React with SSR and I fold some errors.
My code GitHub - PhamMinhKha/hotpic: Cross platform with meteor
package.json

{
  "name": "hotpic",
  "private": true,
  "scripts": {
    "start": "meteor run",
    "test": "meteor test --once --driver-package meteortesting:mocha",
    "test-app": "TEST_WATCH=1 meteor test --full-app --driver-package meteortesting:mocha",
    "visualize": "meteor --production --extra-packages bundle-visualizer"
  },
  "dependencies": {
    "@babel/runtime": "^7.14.0",
    "antd": "^4.14.1",
    "bcrypt": "^5.0.1",
    "body-parser": "^1.19.0",
    "i18next": "^20.1.0",
    "i18next-browser-languagedetector": "^6.1.0",
    "i18next-http-backend": "^1.2.0",
    "meteor-node-stubs": "^1.0.1",
    "moment": "^2.29.1",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-helmet": "^6.1.0",
    "react-i18next": "^11.8.11",
    "react-image-lightbox": "^5.1.1",
    "react-loading-skeleton": "^2.2.0",
    "react-router-dom": "^5.2.0",
    "shelljs": "^0.8.4",
    "slug": "^5.0.1",
    "styled-components": "^5.2.1"
  },
  "meteor": {
    "mainModule": {
      "client": "startup/client.js",
      "server": "startup/server.js"
    },
    "testModule": "tests/main.js"
  },
  "devDependencies": {
    "chai": "^4.3.4"
  }
}
=> Started proxy.                             
=> Started HMR server.                        
=> Started MongoDB.                           
W20210522-09:06:52.177(7)? (STDERR) /Users/phamkha/.meteor/packages/meteor-tool/.2.2.0.1caanc2.am2i++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:280
W20210522-09:06:52.213(7)? (STDERR)                                             throw(ex);
W20210522-09:06:52.213(7)? (STDERR)                                             ^
W20210522-09:06:52.213(7)? (STDERR) 
W20210522-09:06:52.213(7)? (STDERR) ReferenceError: window is not defined
W20210522-09:06:52.213(7)? (STDERR)     at Object.<anonymous> (/Users/phamkha/Desktop/Meteor/hotpic/node_modules/antd/dist/antd.js:18:4)
W20210522-09:06:52.213(7)? (STDERR)     at Module._compile (internal/modules/cjs/loader.js:999:30)
W20210522-09:06:52.214(7)? (STDERR)     at Module.Mp._compile (/Users/phamkha/Desktop/Meteor/hotpic/.meteor/local/build/programs/server/runtime.js:50:23)
W20210522-09:06:52.214(7)? (STDERR)     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
W20210522-09:06:52.214(7)? (STDERR)     at Module.load (internal/modules/cjs/loader.js:863:32)
W20210522-09:06:52.214(7)? (STDERR)     at Module.Mp.load (/Users/phamkha/Desktop/Meteor/hotpic/.meteor/local/build/programs/server/runtime.js:15:31)
W20210522-09:06:52.214(7)? (STDERR)     at Function.Module._load (internal/modules/cjs/loader.js:708:14)
W20210522-09:06:52.214(7)? (STDERR)     at Module.require (internal/modules/cjs/loader.js:887:19)
W20210522-09:06:52.214(7)? (STDERR)     at require (internal/modules/cjs/helpers.js:74:18)
W20210522-09:06:52.214(7)? (STDERR)     at npmRequire (/Users/phamkha/Desktop/Meteor/hotpic/.meteor/local/build/programs/server/npm-require.js:133:12)
W20210522-09:06:52.214(7)? (STDERR)     at Module.useNode (packages/modules-runtime.js:664:18)
W20210522-09:06:52.215(7)? (STDERR)     at module (packages/modules.js:1185:8)
W20210522-09:06:52.215(7)? (STDERR)     at fileEvaluate (packages/modules-runtime.js:336:7)
W20210522-09:06:52.215(7)? (STDERR)     at Module.require (packages/modules-runtime.js:238:14)
W20210522-09:06:52.215(7)? (STDERR)     at Module.moduleLink [as link] (/Users/phamkha/.meteor/packages/modules/.0.16.0.1vgf3j2.535sj++os+web.browser+web.browser.legacy+web.cordova/npm/node_modules/reify/lib/runtime/index.js:52:22)
W20210522-09:06:52.215(7)? (STDERR)     at module (imports/ui/App.jsx:1:466)
W20210522-09:06:52.215(7)? (STDERR)     at fileEvaluate (packages/modules-runtime.js:336:7)
W20210522-09:06:52.215(7)? (STDERR)     at Module.require (packages/modules-runtime.js:238:14)
W20210522-09:06:52.215(7)? (STDERR)     at Module.moduleLink [as link] (/Users/phamkha/.meteor/packages/modules/.0.16.0.1vgf3j2.535sj++os+web.browser+web.browser.legacy+web.cordova/npm/node_modules/reify/lib/runtime/index.js:52:22)
W20210522-09:06:52.215(7)? (STDERR)     at module (startup/server.js:1:257)
W20210522-09:06:52.215(7)? (STDERR)     at fileEvaluate (packages/modules-runtime.js:336:7)
W20210522-09:06:52.215(7)? (STDERR)     at Module.require (packages/modules-runtime.js:238:14)

Sorry my english is not good i use “google translate”

WebApp and SSR are 2 different things.
for SSR, you can follow the Meteor official document: server-render | Meteor API Docs

Does SSR help your website run faster?

Not really. It helps decrease the First Contentful Paint time.
To make it load faster, you need to decrease the bundle size. Code splitting would help.

The error you are seeing is due to antd.js referencing the window object and the execution happening on the server where the window object doesn’t exist.

Also, once you iron out your antd issue, you might check out communitypackages:react-router-ssr

1 Like