Nuxt 3 to Netlify

Nuxt3 setup

if you want to use SPA,need to add ssr:false in defineConfig

run npm run build

run npm run generate (this step will generate dist folder(.output/public))

Netlify Setup

  1. install Netlify CLI Get started with Netlify CLI | Netlify Docs

  2. login your Netlify account through cli

    netlify login
    
  3. Create a new Netlify project or Link your exist Netlify project

    # create new one
    netlify init
    # link exist one
    netlify link # select site ID option and paste your project site ID
    

Deployment

# deploy to netlify
netlify deploy --dir=.output/public --prod

you can add this command into package.json

"scripts": {
    "build": "nuxt build",
    "dev": "nuxt dev --host",
    "generate": "nuxt generate",
    "preview": "nuxt preview",
    "postinstall": "nuxt prepare",
    "deploy": "netlify deploy --dir=.output/public --prod" 
  },