Learn to implement a monorepo with a single Next.js site using Nx.
This is a monorepo example using Nx and a single Next.js site in ./apps/app.
https://solutions-nx-monorepo.vercel.sh
You can choose from one of the following two methods to use this repository:
Deploy the example using Vercel:
Execute
npx create-next-app --example https://github.com/vercel/examples/tree/main/solutions/nx-monorepo nx-monorepo
yarn create next-app --example https://github.com/vercel/examples/tree/main/solutions/nx-monorepo nx-monorepo
pnpm create next-app --example https://github.com/vercel/examples/tree/main/solutions/nx-monorepo nx-monorepo
Run
npx nx serve app
Run
npx nx build app
dist/
--prod
Run
npx nx test app
Run
npx nx affected:test
Run
nx g @nrwl/react:component my-component --project=app
Run
npx nx g @nrwl/react:app new-app
You can use any of the plugins above to generate applications as well.
When using Nx, you can create multiple applications and libraries in the same workspace.
Run
npx nx g @nrwl/react:lib my-lib
You can also use any of the plugins above to generate libraries as well.
Libraries are shareable across libraries and applications. They can be imported from
@with-nx/mylib
Visit the Nx Documentation to learn more.
This example is configured to work out of the box with Nx Cloud. However, if deploying an existing project to Vercel - ensure:
If using
@nrwl/nx-cloud@14.6.0
NX_CACHE_DIRECTORY=/tmp/nx-cache
If using
@nrwl/nx-cloud@14.5.0
NX_CACHE_DIRECTORY=/tmp/nx-cache
cacheDirectory
@nrwl/nx-cloud
nx.json
NX_CACHE_DIRECTORY
"runner": "@nrwl/nx-cloud","options": {// this must be the same value as `NX_CACHE_DIRECTORY`"cacheDirectory": "/tmp/nx-cache"}
Visit Nx Cloud to learn more.
Learn to implement a monorepo with a single Next.js site using Nx.
This is a monorepo example using Nx and a single Next.js site in ./apps/app.
https://solutions-nx-monorepo.vercel.sh
You can choose from one of the following two methods to use this repository:
Deploy the example using Vercel:
Execute
npx create-next-app --example https://github.com/vercel/examples/tree/main/solutions/nx-monorepo nx-monorepo
yarn create next-app --example https://github.com/vercel/examples/tree/main/solutions/nx-monorepo nx-monorepo
pnpm create next-app --example https://github.com/vercel/examples/tree/main/solutions/nx-monorepo nx-monorepo
Run
npx nx serve app
Run
npx nx build app
dist/
--prod
Run
npx nx test app
Run
npx nx affected:test
Run
nx g @nrwl/react:component my-component --project=app
Run
npx nx g @nrwl/react:app new-app
You can use any of the plugins above to generate applications as well.
When using Nx, you can create multiple applications and libraries in the same workspace.
Run
npx nx g @nrwl/react:lib my-lib
You can also use any of the plugins above to generate libraries as well.
Libraries are shareable across libraries and applications. They can be imported from
@with-nx/mylib
Visit the Nx Documentation to learn more.
This example is configured to work out of the box with Nx Cloud. However, if deploying an existing project to Vercel - ensure:
If using
@nrwl/nx-cloud@14.6.0
NX_CACHE_DIRECTORY=/tmp/nx-cache
If using
@nrwl/nx-cloud@14.5.0
NX_CACHE_DIRECTORY=/tmp/nx-cache
cacheDirectory
@nrwl/nx-cloud
nx.json
NX_CACHE_DIRECTORY
"runner": "@nrwl/nx-cloud","options": {// this must be the same value as `NX_CACHE_DIRECTORY`"cacheDirectory": "/tmp/nx-cache"}
Visit Nx Cloud to learn more.