| title | Deploy your web app to Azure Static Web Apps. |
|---|---|
| description | Learn to deploy your web app to Azure Static Web Apps. |
| services | static-web-apps |
| author | cjk7989 |
| ms.service | azure-static-web-apps |
| ms.topic | article |
| ms.date | 09/18/2024 |
| ms.author | jikunchen |
| zone_pivot_groups | swa-web-framework |
In this article, you create a new web app with the framework of your choice, run it locally, then deploy to Azure Static Web Apps.
To complete this tutorial, you need:
| Resource | Description |
|---|---|
| Azure subscription | If you don't have one, you can create an account for free. |
| Node.js | Install version 20.0 or later. |
| Azure CLI | Install version 2.6x or later. |
You also need a text editor. For work with Azure, Visual Studio Code is recommended.
You can run the app you create in this article on the platform of your choice including: Linux, macOS, Windows, or Windows Subsystem for Linux.
- Open a terminal window.
::: zone pivot="vanilla-js"
-
Select an appropriate directory for your code, then run the following commands.
npm create vite@latest swa-vanilla-demo -- --template=vanilla cd swa-vanilla-demo npm install npm run devAs you run these commands, the development server prints the URL of your website. Select the link to open it in your default browser.
::: zone-end
::: zone pivot="angular"
-
Select an appropriate directory for your code, then run the following commands.
npx --package @angular/cli@latest ng new swa-angular-demo --ssr=false --defaults cd swa-angular-demo npm startAs you run these commands, the development server prints the URL of your website. Select the link to open it in your default browser.
::: zone-end
::: zone pivot="react"
-
Select an appropriate directory for your code, then run the following commands.
npm create vite@latest swa-react-demo -- --template react cd swa-react-demo npm install npm run devAs you run these commands, the development server prints the URL of your website. Select the link to open it in your default browser.
::: zone-end
::: zone pivot="vue"
-
Select an appropriate directory for your code, then run the following commands.
npm create vite@latest swa-vue-demo -- --template vue cd swa-vue-demo npm install npm run devAs you run these commands, the development server prints the URL of your website. Select the link to open it in your default browser.
::: zone-end
- Select Cmd/Ctrl+C to stop the development server.
[!INCLUDE Create an Azure Static Web App]
[!INCLUDE Build your site for deployment]
::: zone pivot="angular"
Warning
Angular v17 and later place the distributable files in a subdirectory of the output path that you can choose. The SWA CLI doesn't know the specific location of the directory. The following steps show you how to set this path correctly.
Locate the generated index.html file in your project in the dist/swa-angular-demo/browser folder.
-
Set the
SWA_CLI_OUTPUT_LOCATIONenvironment variable to the directory containing the index.html file:export SWA_CLI_OUTPUT_LOCATION="dist/swa-angular-demo/browser"
setenv SWA_CLI_OUTPUT_LOCATION "dist/swa-angular-demo/browser"$env:SWA_CLI_OUTPUT_LOCATION="dist/swa-angular-demo/browser"
set SWA_CLI_OUTPUT_LOCATION="dist/swa-angular-demo/browser"
::: zone-end
Deploy your code to your static web app:
npx swa deploy --env productionIt might take a few minutes to deploy the application. Once complete, the URL of your site is displayed.
On most systems, you can select the URL of the site to open it in your default browser.
[!INCLUDE Clean up resources]
[!div class="nextstepaction"] Add authentication




