- Github Repo: https://github.com/basir/next-tailwind-amazona
- npx create-next-app next-tailwind-amazona
// syntax: npx create-next-app my-app
npm run dev
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p (it creates postcss.config.js, tailwind.config.js)
iii) add below lines in tailwind.config.js inside content
content: [
"./pages/**/*.{js,ts,jsx,tsx}",
"./components/**/*.{js,ts,jsx,tsx}",
],
v) add below lines in globals.css (at the top)
@tailwind base;
@tailwind components;
@tailwind utilities;
- Delete Home.module.css and remove the import for that from index.js
- remove main section from index.js file
- create components folder and create Layout.js file
- in eslintrc.json, make string to array and add the eslint:recommended
{
"extends": ["eslint:recommended", "next/core-web-vitals"]
}
-
List Products i) create utils folder and add data.js ii) add images iii) add ProductItem.js file in components folder
-
Create a new folder under pages folder called product and create a new file called [slug].js
-
npm i -D @types/react
-
Create a new file Store.js under utils folder.
-
Create a new file cart.js under pages folder
-
npm i @heroicons/react
-
npm i js-cookie (see in Store.js for usage of this)
-
Create a new file under pages folder (login.js)
-
npm i react-hook-form
-
Create a new file under utils folder (db.js)
-
npm i mongoose
-
npm i bcryptjs
-
Create a new file called seed.js under pages--->api folder
-
Create a new folder called models on root folder and create a new file under that folder called User.js
-
run your local and check this below URL endpoint in the browser after handler function is implemented in seed.js
http://localhost:3000/api/seed
-
npm i next-auth (you can read the next.js auth documentation regarding this)
-
create a new folder called auth and create a new file called [...nextauth].js
-
Create a new file called error.js under utils folder
-
npm i react-toastify
-
npm i @headlessui/react
-
Create a new file DropdownLink.js inside the components folder
-
Create a new file under pages folder called shipping.js
-
Create a new file under components folder called CheckoutWizard.js
-
Create a new file under pages folder called unauthorized.js
-
Create a new file under pages folder called payment.js
-
Create a new file under models folder called Product.js
-
Loading products from MongoDB instead of data.products in index.js file (Home Component)
-
After writing the getServerSideProps logic we have to convertDocToObj for products id (this is handled in db.js)
-
npm i axios
-
Create a new folder inside pages --> api folder and name it as products
-
Create a new file called [id].js inside the products folder which is created as per 38th point