NuxtJS: How to turn off SSR for only certain pages


How to turn off SSR for only certain pages

Solution: use server middleware

Step 1: create file middleware/render.js

export default function(req, res, next) {
    const paths = ['/bootstrap/chart'] //you can edit to your own pages
  
    if (paths.includes(req.originalUrl)) {      
      res.spa = true
    }
     
    next && next.call && next()
}

Step 2: Edit File nuxt.config.js

export default {
  ...
  //ssr: false // Disable Server Side rendering
  serverMiddleware: [ '~/middleware/render' ],
}

Leave a Reply