Skip to main content

About SWA CLI

The Static Web Apps (SWA) CLI is an open-source commandline tool that streamlines local development and deployment for Azure Static Web Apps.

contributions welcome


Static Web Apps

Azure Static Web Apps is a turnkey service for modern full-stack applications with pre-built or pre-rendered front-ends, and serverless backends. It became generally available in May 2021.

The Static Web Apps architecture views web apps as two components:

  • static content like HTML, CSS, JS and media assets
  • dynamic API for client interactions requiring data or processing

This allows the architecture to scale each component using technologies best suited to its type and purpose. Static content is hosted in globally-distributed content servers for fast delivery. Dynamic APIs are implemented using a serverless architecture, for cost-effective scaling on-demand.

Static Web Apps Architecture

Developer benefits to using Static Web Apps:

Visit the Azure Static Web Apps Documentation for more information.

About SWA CLI

The Static Web Apps CLI (SWA CLI or swa) is an open-source command-line tool to streamline the local development experience for Azure Static Web Apps - from setup to deployment.

Key Features of SWA CLI:

  • Serve static app assets, or proxy to your app dev server
  • Serve API requests or proxy to APIs in Azure Functions Core Tools
  • Emulate authentication and authorization (with mock responses)
  • Emulate Static Web Apps configuration (for routing & role-based auth)
  • Deploy to Azure Static Web Apps (streamlined develop-deploy workflow)

Components of CLI

The figure illustrates the high-level architecture for the Static Web Apps CLI, identifying the key components and their relationships:

Static Web Apps CLI Architecture

1. Reverse Proxy: This is the heart of SWA CLI. It intercepts and forwards HTTP requests to the right components based on the purpose:

  • /.auth/** requests => forwarded to the Auth emulator server.
  • /api/** requests => forwarded to localhost functions (if present).
  • /** => all other requests forwarded to the static assets content server.

2. Authentication Server (Emulator):

  • Emulates auth flow
  • Returns mock responses.

3. Static Content Server.

  • Serves static assets (HTML, CSS, JS, media files)
  • Useful for local testing, validation of user experience
  • Default target for requests not handled by other components

4. Serverless API server.

  • Useful for local API testing (if used)
  • Requires (and has API endpoints served by) Azure Functions Core Tools.
Always test on Azure for production!

The Static Web Apps CLI is a convenience for local development and testing. It uses emulated services so differences from real-world behaviors are to be expected. Always test final application on Azure using preview and production environments, to validate behavior.

Contributing to CLI

This is an open-source project made for the benefit of our developer community. Your feedback and contributions are key to its success.

Here are some ways to help:

Contribute directly to the project by fixing bugs, writing (or improving) documentation, and proposing (or implementing) new features. To start:

Thank you for your continued support! ♥️