Getting started
You need an Nx workspace. If you already have one, skip the first step. Compatibility lists the supported versions.
Create a workspace
Section titled “Create a workspace”pnpm dlx create-nx-workspace@latest acme --preset=ts --pm=pnpmcd acmenpx create-nx-workspace@latest acme --preset=ts --pm=npmcd acmenpx create-nx-workspace@latest acme --preset=ts --pm=yarncd acmeInstall the plugin
Section titled “Install the plugin”pnpm add -Dw @geekvetica/nx-astropnpm exec nx g @geekvetica/nx-astro:init-w adds the package to the workspace root. If pnpm stops with ERR_PNPM_IGNORED_BUILDS, choose which install scripts may run with pnpm approve-builds, then run the command again.
npm install --save-dev @geekvetica/nx-astronpx nx g @geekvetica/nx-astro:inityarn add -D @geekvetica/nx-astroyarn nx g @geekvetica/nx-astro:initYarn Classic needs yarn add -D -W in a workspace root.
init registers the plugin in nx.json and installs Astro if the workspace has none. The init reference lists what it changes.
Generate an application
Section titled “Generate an application”nx g @geekvetica/nx-astro:application my-appThis creates apps/my-app with one page and five targets. Every file and option is in the application reference.
Run it
Section titled “Run it”Start the development server. It listens on port 4321, unless the Astro config sets another one:
nx dev my-appBuild the site into dist/apps/my-app:
nx build my-appServe the built site:
nx preview my-appRun the build again without a change and Nx restores the result from its cache.
Check the types
Section titled “Check the types”Type checking needs @astrojs/check:
pnpm add -Dw @astrojs/checknpm install --save-dev @astrojs/checkyarn add -D @astrojs/checknx check my-app