How to deploy a finished nuxt.js app to a webserver?
The simplest way - you need to generate all the content:
- Run
npm run generate
. - Go to the
dist
subfolder of your project and copy all from there to some public hosting, like GitHub Pages.
Though if you have some content depended from the user, you need to deploy it as a SPA:
- Change
mode
innuxt.config.js
tospa
. - Run
npm run build
. - Deploy the created
dist/
folder to your static hostings like Surge, GitHub Pages or nginx.
More details:
https://nuxtjs.org/guide/commands#static-generated-deployment-pre-rendered-
https://nuxtjs.org/faq/github-pages#how-to-deploy-on-github-pages-
There is no one answer to this question and the main variables are, are you deploying a static app, or a universal (ssr) app and where do you want to host it.
Static apps are pretty straight forward as suggested in the comments and other answer, but chances are you've got a SSR app and need to deploy that.
The docs have details on deploying to a range of hosting providers as well as a bit about using nginx.
There is a tutorial to deploy to digital ocean.
Some hosting providers are easier than others, and really the ones that provide a CLI to deploy from are usually easier. Therefore Heroku is a good choice as are Now and Netlify, but the later two are only for static apps. The docs say that "AWS is a death by 1000 paper cuts", so I guess that's not easy.
So you should check out your hosting options and choose one, try and follow the nuxt docs to deploy and if you get stuck, ask another question here with specifics.