This is a Next.js project bootstrapped with create-next-app
.
Use following command (using npm)
npx create-next-app@latest --ts nextjs-shop-sample --use-npm
First, run the development server:
npm run dev
# or
yarn dev
Open http://localhost:3000 with your browser to see the result.
You can start editing the page by modifying pages/index.tsx
. The page auto-updates as you edit the file.
API routes can be accessed on http://localhost:3000/api/hello. This endpoint can be edited in pages/api/hello.ts
.
The pages/api
directory is mapped to /api/*
. Files in this directory are treated as API routes instead of React pages.
npm install --save styled-components
npm install --save-dev @types/styled-components
# install
npx sb@latest init
# add plugin or library
npm install --save-dev @storybook/addon-postcss \
tsconfig-paths-webpack-plugin \
@babel/plugin-proposal-class-properties \
@babel/plugin-proposal-private-methods \
@babel/plugin-proposal-private-property-in-object \
tsconfig-paths-webpack-plugin \
@mdx-js/react
# run storybook
npm run storybook
If following error occurs, fix .storybook/main.js
Cannot find module ~~~
# .storybook/main.js
module.exports = {
"typescript" : { reactDocgen: false }, # <- add
"stories": [ .....
This issues on GitHub.
npm install --save-dev jest \
@testing-library/react \
@testing-library/jest-dom \
jest-environment-jsdom
Add jest.setup.js
file and jest.config.js
at root directry. Next, add "test": "jest"
on package.json file.
npm install --save-dev prettier eslint typescript-eslint \
@typescript-eslint/eslint-plugin \
@typescript-eslint/parser \
eslint-config-prettier \
eslint-plugin-prettier \
eslint-plugin-react \
eslint-plugin-react-hooks \
eslint-plugin-import
Fix package.json
file.
"lint": "next lint --dir src"
Use Lint, following command.
npm run lint
Fix package.json
file.
"format": "next lint --fix --dir src"
Use Format, following command.
npm run format
npm install react-hook-form
npm install swr
npm install react-content-loader
npm install --save-dev @types/react-content-loader
npm install @mui/material \
@mui/icons-material \
@emotion/react \
@emotion/styled
docker image build -t `image-name`:`version` .
docker container run -d -p 3000:3000 `nextjs-shop-sample:v0.1`
You want to deploy on Azure, reference this web site.
Notice
At first deploy on Azure, you may run following command. This is because the resource provider has not been assigned to Azure Container Service.
az provider register --namespace Microsoft."resource provider name"
To learn more about Next.js, take a look at the following resources:
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!