Build an inventory management app with Azure Static Web Apps with + React, part 1

That is a part of #30DaysOfSWA

On this sequence, I will take you from the very starting on producing a React app and deploying it inside 5 minutes. Within the upcoming components, I will maintain constructing on the identical app, and add issues like backend and different issues.


You’re looking at prototyping a brand new stock administration system. There are two stuff you wish to take a look at out:

  • React, you need that shopper like expertise, you hear quite a lot of firms are utilizing React.
  • Azure Static Web Apps, there’s this service on Azure that not solely allows you to retailer static recordsdata, however you possibly can add a backend and auth to it.

Time to judge.

Create a React App

To construct your frontend app, you wish to rise up and working quick. You begin studying up and understand there’s quite a lot of methods to get began:

You have a look at Snowpack and it seems like only a few instructions to get began, and also you resolve to provide it a strive.

Generate venture utilizing Snowpack

To create a venture with Snowpack, it is one line of code:

  1. Run the beneath command to generate a Snowpack venture:

    npx create-snowpack-app react-snowpack --template @snowpack/app-template-minimal

    You get a set of recordsdata, at this level, you’ve gotten a Snowpack venture however probably not a React app.

    Lets see that it really works although:

  2. Run the beneath instructions to start out your Snowpack generated app:

   cd react-snowpack
   npm run begin
Enter fullscreen mode

Exit fullscreen mode

In a browser, at http://localhost:8080/, it is best to see “Welcome to Snowpack”.

Add React

Let’s add the wanted dependencies subsequent so as to add help for React:

  1. Run npm set up to put in React:

    npm set up react react-dom --save
  2. Run mv to rename your index.js to index.jsx:

    mv index.js index.jsx

    Now, you’ve gotten a file wherein you’ll bootstrap your React app.

  3. In index.jsx, add the beneath code:

    import React from 'react';
    import ReactDOM from 'react-dom';
    import {StrictMode} from 'react';
    import {createRoot} from 'react-dom/shopper';
    import App from './App'
    const rootElement = doc.getElementById('root');
    const root = createRoot(rootElement);
        <App />
  4. Create App.jsx and provides it the next code:

    import React from 'react';
    perform App() {
      return (<div>App</div>)
    export default App
  5. Modify index.html and provides it the next component:

     <div id="root"></div>

    At this level, you’ve gotten a working React app. Attempt working it domestically with npm begin.

Plan your deployment

In an effort to use Azure Static Internet App, we have to first:

  • Create a GitHub repo.
  • Create a neighborhood repo and sync with GitHub repo.
  • Add a commit.

Create repo

Go to GitHub and create a repo, identify it something you need, in beneath instance, we have named snowpack-demo.

Run the beneath instructions in your console:

  echo "# snowpack-demo" >>
  git init
  git add.
  git commit -m "first commit"
  git department -M essential
  git distant add origin
  git push -u origin essential
Enter fullscreen mode

Exit fullscreen mode

Your app is now pushed to your GitHub repo. Subsequent, let’s deploy to Azure.


Guarantee you’ve gotten downloaded the Azure Static Internet Apps extension for Visible Studio code, and in addition guarantee you’ve gotten an Azure account.

  1. Choose Azure brand within the left menu in Visible Studio Code.
  2. Choose the + icon in Static Internet Apps part.
  3. Comply with the sequence of steps
    1. Choose subscription
    2. Give identify of app
    3. Location of app / (when you’ve got your app in sub listing app, you have to sort /app)
    4. Choose template, React.
    5. Specify folder the place your app is constructed construct

Your app is now deploying, now you can both click on the message popup that claims “open actions in GitHub” or go to your repo on GitHub and the actions tab. 1-2 min later, or much less, you can be proven a deploy URL in Visible Studio Code, choose it.

Congrats, you deployed your app to Azure. This is my app:

What’s subsequent

You might have simply began; this was half 1. Within the subsequent half, we can be enhancing our app by giving it a greater UI and help routing. All through all this, Azure Static Internet App will help us.

Add a Comment

Your email address will not be published. Required fields are marked *