You might want to use your own server with your middleware and your API. That’s why you can use Nuxt.js programmatically.

Nuxt Constructor

To see the list of options to give to Nuxt.js, see the configuration section.

  1. const { loadNuxt, build } = require('nuxt')
  2. // Check if we need to run Nuxt in development mode
  3. const isDev = process.env.NODE_ENV !== 'production'
  4. // Get a ready to use Nuxt instance
  5. const nuxt = await loadNuxt(isDev ? 'dev' : 'start')
  6. // Enable live build & reloading on dev
  7. if (isDev) {
  8. build(nuxt)
  9. }
  10. // We can use `nuxt.render(req, res)` or `nuxt.renderRoute(route, context)`

You can take a look at the nuxt-express and adonuxt starters to get started quickly.

Debug logs

If you want to display Nuxt.js logs, you can add the following to the top of your file:

  1. process.env.DEBUG = 'nuxt:*'