Skip to main content

1. Install the SWA CLI

You can install the Static Web Apps CLI using npm, yarn or pnpm.

:::

Installing the CLI

See: @azure/static-web-apps-cli .

  1. To install this globally, use:
npm install -g @azure/static-web-apps-cli
Note

You can also install the SWA CLI inside a project (instead of globally) as a development dependency using:

npm install -D @azure/static-web-apps-cli

Validate the install

Installing the package will make the swa command available on your development machine. To validate your install, you can check the installed version with:

swa --version
# Should print out the version number

Basic usage

The best way to get started is to run the swa command alone and follow the interactive prompts.

swa

It will generate a configuration for you, then build your project and ask if you want to deploy it to Azure.

See swa for more details.

Extended usage

Here are the currently supported swa commands. Use swa <command> --help to learn about options and usage for that particular command.

  • login: login into Azure
  • init: initialize a new static web app project
  • start: start the emulator from a directory or bind to a dev server
  • deploy: deploy the current project to Azure Static Web Apps
  • build: build your project

Run using npx

The npx command (aka "npm exec") lets you run an arbitrary command from a local or remote npm package. If the command was not installed globally on the device, this installs it for you in a central cache - making it a useful option if you want to use different versions of the same command on the local device.

You can run any Static Web Apps CLI commands directly using npx. For example:

npx @azure/static-web-apps-cli --version

Or use this command to start the emulator:

npx @azure/static-web-apps-cli start