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 require Nuxt.js like this:
const { Nuxt, Builder } = require('nuxt')
To see the list of options to give to Nuxt.js, see the configuration section.
// Require `Nuxt` And `Builder` modules
const { Nuxt, Builder } = require('nuxt')
// Require Nuxt config
const config = require('./nuxt.config.js')
// Create a new Nuxt instance
const nuxt = new Nuxt(config)
// Enable live build & reloading on dev
if (nuxt.options.dev) {
new Builder(nuxt).build()
}
// 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.
If you want to display nuxt.js logs, you can add to the top of your file:
process.env.DEBUG = 'nuxt:*'
Caught a mistake or want to contribute to the documentation? Edit this page on GitHub!