| author | cjk7989 |
|---|---|
| ms.author | jikunchen |
| ms.service | azure-static-web-apps |
| ms.topic | include |
| ms.date | 07/02/2024 |
-
Add a
staticwebapp.config.jsonfile to your application code with the following contents:{ "navigationFallback": { "rewrite": "/index.html" } }Defining a fallback route allows your site to server the
index.htmlfile for any requests made against the domain.Check this file into your source code control system (such as git) if you're using one.
-
Install the Azure Static Web Apps (SWA) CLI in your project.
npm install -D @azure/static-web-apps-cli
The SWA CLI helps you develop and test your site locally before you deploy it to the cloud.
-
Create a new file for your project and name it
swa-cli.config.json.The
swa-cli.config.jsonfile describes how to build and deploy your site.Once this file is created, you can generate its contents using the
npx swa initcommand.npx swa init --yes
-
Build your application for distribution.
npx swa build
-
Use the SWA CLI to sign into Azure.
npx swa login --resource-group swa-tutorial --app-name swa-demo-site
Use the same resource group name and static web app name that you created in the previous section. As you attempt to log in, a browser opens to complete the process if necessary.