dnitsch / static-web-apps-cli

Azure Static Web Apps CLI ✨

Home Page:https://aka.ms/swa/cli-local-development

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Azure Static Web Apps CLI

logo

The Static Web Apps CLI, also known as SWA CLI, serves as a local development tool for Azure Static Web Apps. It can:

  • Serve static app assets, or proxy to your app dev server
  • Serve API requests, or proxy to APIs running in Azure Functions Core Tools
  • Emulate authentication and authorization
  • Emulate Static Web Apps configuration, including routing and ACL roles
  • Deploy your app to Azure Static Web Apps

Important Notes

If you have suggestions or you encounter issues, please report them or help us fix them. Your contributions are very much appreciated. 🙏

The CLI emulates commonly used capabilities of the Azure Static Web Apps cloud service. Some differences are expected. Always deploy and test your apps in Azure to confirm behavior.

Quickstart

Installing the CLI with npm, yarn or pnpm:

  • To install the CLI globally, use:

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

    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. This is highly recommended.

Basic usage

  • Open a SWA app folder at the root (outside any /api or /app folders):

    cd my-awesome-swa-app
  • 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

Using npx:

  • Open a SWA app folder at the root (outside any /api or /app folders):
cd my-awesome-swa-app
  • Create a configuration for your project:
npx @azure/static-web-apps-cli init
  • Start the emulator:
npx @azure/static-web-apps-cli start
  • Access your SWA app from http://localhost:4280

See all available commands and options.

Want to help?

Want to file a bug, contribute some code, or improve the documentation? Excellent! Read up on our guidelines for contributing and then check out one of our issues in the list: community-help.

About

Azure Static Web Apps CLI ✨

https://aka.ms/swa/cli-local-development

License:MIT License


Languages

Language:TypeScript 42.6%Language:JavaScript 26.9%Language:HTML 8.4%Language:CSS 6.2%Language:SCSS 2.9%Language:Vue 1.9%Language:Shell 1.4%Language:Svelte 1.4%Language:Astro 1.4%Language:C++ 1.2%Language:Handlebars 1.2%Language:Ruby 0.8%Language:C# 0.7%Language:CMake 0.6%Language:Python 0.4%Language:Dart 0.4%Language:Pug 0.4%Language:MDX 0.2%Language:Dockerfile 0.2%Language:CoffeeScript 0.2%Language:Makefile 0.2%Language:Marko 0.1%Language:Elm 0.1%Language:C 0.1%Language:Riot 0.1%Language:EJS 0.0%Language:Swift 0.0%Language:Stylus 0.0%Language:Kotlin 0.0%Language:Objective-C 0.0%