Using Nuxt.js Programmatically
You might want to use your own server with your middleware and your API. That’s why you can use Nuxt.js programmatically. You can see programmatic examples at examples/programmatic.
Nuxt Constructor
To see the list of options to give to Nuxt.js, see the configuration section.
const { loadNuxt, build } = require('nuxt')
// Check if we need to run Nuxt in development mode
const isDev = process.env.NODE_ENV !== 'production'
// Get a ready to use Nuxt instance
const nuxt = await loadNuxt(isDev ? 'dev' : 'start')
// Enable live build & reloading on dev
if (isDev) {
build(nuxt)
}
// 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:
process.env.DEBUG = 'nuxt:*'