NX is a tool for managing monorepos.

This guide shows you how to create a connector for your NX application on the Moovweb XDN. Here we use Next.js for the default NX project.

In the root of your nx monorepo, run:

npm i -g @xdn/cli
xdn init

Since our Next.js app isn't located in the root of the project as the @xdn/next connector expects, we'll need to define our own custom connector. To do so:

  1. Set connector: './xdn' in xdn.config.js
  2. Copy the xdn directory from the example into the root of your monorepo.

const { Router } = require('@xdn/core/router')
const { default: NextRoutes } = require('@xdn/next/router/NextRoutes')

module.exports = new Router()
  .match('/service-worker.js', ({ serviceWorker }) => {
    return serviceWorker('.next/static/service-worker.js')
  })
  .use(new NextRoutes('apps/next-app')) // provide the path to your Next.js app relative to the root of the monorepo here

To run your Next.js app in development mode behind the XDN, run:

xdn dev

To deploy your app to the XDN, run:

xdn deploy