Code Monkey home page Code Monkey logo

nextjs-azure-static-web-app-accelerator's Introduction

Azure Static Web Apps CI/CD

Its primary goal of this repo is to provide a simple Next JS application (using App Routes) along with an example Azure Dev Ops pipeline and GitHub action to provide ability to deploy the app to an Azure Static Web App. See Deploy on Azure Static Web Apps for instructions on deployments.

It also includes:

Table of Contents

The Next.js App

This is a Next.js project bootstrapped with create-next-app.

Getting Started

First, run the development server:

npm run dev
# or
yarn dev
# or
pnpm dev

Open http://localhost:3000 with your browser to see the result.

This project uses next/font to automatically optimize and load Inter, a custom Google Font.

Styling

This app leverages PostCSS and Tailwind. There are the beginnings of a theme in src/styles/globals.css

Structure

๐Ÿ“ฆ โ”ฃ ๐Ÿ“‚ docs (assets referenced by this readme) โ”ฃ ๐Ÿ“‚ src โ”ƒ โ”ฃ ๐Ÿ“‚ app โ”ƒ โ”ƒ โ”ฃ ๐Ÿ“‚ components (contains page-specific and shared components) โ”ƒ โ”ƒ โ”ƒ โ”ฃ ๐Ÿ“‚ shared (shared components) โ”ƒ โ”ฃ ๐Ÿ“‚ hooks (contains React hooks for reusable functionality) โ”ƒ โ”ฃ ๐Ÿ“‚ images (contains pngs etc) โ”ƒ โ”ฃ ๐Ÿ“‚ styles (contains CSS files) โ”ƒ โ”ฃ ๐Ÿ“‚ types (TS types)

Unit Tests

Component tests using React Testing Library and Jest sit next to the corresponding component file, e.g. Spinner.test.tsx.

Unit tests can be run using npm run test and are also ran as part of the CI/CD pipeline.

Storybook

This app includes Storybook to provide a component library, presenting each component along with documentation outside of any business logic or context.

"Storybook is packaged as a small, development-only, workshop that lives alongside your app. It provides an isolated iframe to render components without interference from app business logic and context. That helps you focus development on each variation of a component, even the hard-to-reach edge cases."

Each component is described by a 'story' which displays the component and its variations/states. For example Spinner.stories.ts sits next to the Spinner.tsx component file in the folder structure. You can view the Storybook component library by running npm run storybook and browsing the library at http://localhost:6006/.

Deploy on Azure Static Web Apps

Deploying the app is simple, firstly create a new Azure Static Web App - see https://learn.microsoft.com/en-us/azure/static-web-apps/get-started-portal?tabs=vanilla-javascript&pivots=github

As this repo includes a working GitHub action and ADO pipeline you can skip the repository integration step and choose 'Other'

deployment choice

In order to allow either the ADO pipeline, or the GitHub action to connect to your new app you will need to acquire the deployment token and add it as a variable.

  • if wish to use the GitHub Action then you will need to add the deployment token as a repository secret called AZURE_STATIC_WEB_APPS_API_TOKEN github repository secret
  • if you wish to use the Azure DevOps pipeline then you will need to add the deployment token as a variable called AZURE_STATIC_WEB_APPS_API_TOKEN in a variable group named 'ui-variables' ado variable
  • an optional BUILD_VERSION can be added, mapped to the $(Build.BuildNumber) variable. This will be rendered on the /config page on the app to help inform the user as to what version of the app has been deployed.

Learn More About Next.js

To learn more about Next.js, take a look at the following resources:

You can check out the Next.js GitHub repository - your feedback and contributions are welcome!

nextjs-azure-static-web-app-accelerator's People

Contributors

speaktosteve avatar

Stargazers

Jeremy Pridgen avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.