title | desc |
---|---|
Deploying SSR |
(@quasar/app-vite) How to publish a Quasar server-side rendered app. |
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.
If you are deploying to a Serverless service, then please read about SSR Webserver on how to prepare for it.
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.
:::
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"
}
You can use Cleavr to deploy Quasar SSR apps to several popular VPS providers. Cleavr will automatically set up PM2 with cluster mode enabled for your app.
Add a new NodeJS SSR site to Cleavr and then configure the web app settings with the following:
- Entry point: index.js
- Build command: npx quasar build --mode ssr
- Artifact path: dist/ssr