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. This boots up the webserver and starts listening for connections.

TIP

The distributables folder generated after building your app is standalone. It does NOT require the rest of your project folder to work and it does NOT depend on @quasar/cli being installed.

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

There are several ways to use the v1 of now’s services:

The robust way is to add the following file to /dist/ssr/now.json , and it should look like this:

{
  "name": "Your Project Name",
  "version": 1
}

And then cd into the distributables folder and run $ now. If you do it this way, then you can also execute directly from a github repo, but we’ll leave the details of setting that up to you.

If you prefer, however, to set the version from the command line, you can also run now -V 1.

At any rate, you might want to use a “now alias” or connect your domain to Now. And you’re done!

Now.sh will install the dependencies automatically then run $ yarn start. Your website will be up and running on an HTTPS connection in a matter of seconds!