Install the Static Web Apps CLI (SWA CLI)
You have different options available to install the Azure Static Web Apps CLI. The Azure Static Web Apps CLI requires that you have Node.js installed locally. By default, Node.js comes with the Node Package Manager (npm), though you may opt to use other package managers such as Yarn or pnpm.
Resource | Command |
---|---|
npm |
npm install -g @azure/static-web-apps-cli |
yarn |
yarn add @azure/static-web-apps-cli |
pnpm |
pnpm install -g @azure/static-web-apps-cli |
Note
SWA CLI only supports Node versions 16 and below.
Validate install
Installing the package makes the swa
command available on your machine. You can verify the installation is successful by requesting the CLI version.
swa --version
# When installed, the version number is printed out
Usage
To begin using the CLI, you can run the swa
command alone and follow the interactive prompts.
The SWA CLI interactive prompts help guide you through the different options important as you develop your web app.
Run the swa
command to begin setting up your application.
swa
The swa
command generates a configuration file, builds your project, and gives you the option to deploy to Azure.
For details on all the SWA CLI commands, see the CLI reference.
Using npx
You can run any Static Web Apps CLI commands directly using npx. For example:
npx @azure/static-web-apps-cli --version
Alternatively, you can start the emulator via the start
command:
npx @azure/static-web-apps-cli start