[Vuejs]-How to deploy nuxt.js with mongodb on cpanel

0👍

For Nuxt, it depends on your build target and app mode. Are you using SPA or universal?

If you are using SPA, this can be packaged using nuxt build. This output can then be hosted the cpanel as a normal static site using something like Apache.

If you are using universal mode, you will have to ensure you are generating a static site using target:'static'. Once you’ve configured that in your nuxt.config.js, you’ll be able to run nuxt generate and upload the built files to your cpanel.

Please take a look at the Nuxt page for static generation.

That said, I’d wholly recommend you don’t use cpane or hostgator. Such hosting doesn’t scale and relies on technology like Apache that is resource heavy and slow.

I’d suggest you deploy your Nuxt site to Vercel by following this tutorial here

Vercel is free for non-commercial use and scales infinitely based on your usage. It’s incredibly fast and optimised for these types of sites. Deployment is a breeze.

You won’t be able to deploy the MongoDB instance on the cpanel unless you have VPS access, or the cpanel has a pre-configured option.

I recommend you use MongoDB Atlas to easily provision, configure and manage your MongoDB instance.

When combined with Vercel, this should give you an incredibly easy and also performant deployment of your application.

Leave a comment