Deploying SSR
When deploying as a SPA or PWA, the distributables folder that gets generated by Quasar CLI can be served by a static webserver. However, this not the case with a SSR (Server-side Render) build. Your distributables, in this case, contain your production webserver too – which can be tweaked from /src-ssr
.
By default, the SSR distributables use Express, but you can replace it with your webserver of choice.
The Distributables Folder
After building your app on SSR mode ($ quasar build -m ssr
) the folder that gets generated contains a standalone webserver tweaked for serving with SSR.
You’ll notice that it contains a package.json
file of its own. It has an npm script defined, called “start”:"scripts": {
"start": "node index.js"
}
So what you need to do when deploying is to copy this distributables folder on your server, yarn/npm install the dependencies inside it, then run $ yarn start
or $ npm run start
. This boots up the webserver and starts listening for connections.
Enhancing Performance
By default, the webserver runs on only one of the available server’s cores. What you could do is make it use all cores. There is a solution for this: PM2.
After installing PM2 on your server, your npm start script can look like this instead:"scripts": {
"start": "pm2 start index.js"
}
Deploying with Now.sh
Deploying with Now is a breeze. All you need to do is to follow their installation instructions. They recommend downloading “Now Desktop” but you can skip that and directly install the Now CLI:$ npm install -g now
$ now login
Then, you cd into the distributables folder and run $ now
. You might want to use a “now alias” or connect your domain to Now. And you’re done!
Now.sh
will npm install the dependencies automatically then run $ npm run start
. Your website will be up and running on an HTTPS connection in a matter of seconds!