We can deploy a Nuxt SPA just like we can deploy universal SSR Nuxt apps if we have a Node.js runtime server. If we don't, then we can only deploy the SPA as a static site to a static hosting server such as GitHub Pages. You can deploy a static-generated Nuxt SPA as follows:
- Make sure that you have set the value to spa in the mode option in the Nuxt config file:
// nuxt.config.js
export default {
mode: 'spa'
}
- Make sure you have the following run scripts in the package.json file as well:
{
"scripts": {
"generate": "nuxt generate"
}
}
- Run npm run generate, just like you would for the universal SSR Nuxt app. You should see the following output in the terminal:
ℹ Generating output directory: dist/
ℹ Generating pages
✓ Generated /about
✓ Generated /login
✓ Generated /secret
✓ Generated /users
✓ Generated /
In the preceding output, if you navigate to the /dist/ folder inside...