Next.js 14 full-stack app project using app router, server actions, MongoDB, Auth.js. Learn Next.js in 2024.
YT : https://youtu.be/vCOSTG10Y4o?si=y-5gJhckcp25vqLw
The project was created using create-next-app
which sets up everything automatically for you.
npx create-next-app@latest
First, install the dependencies:
npm install
Run the development server:
npm run dev
Open http://localhost:3000 with your browser to see the result.
-
id : fromclient1
-
pwd : fromclient1
-
id : brucewayne1
-
pwd : brucewayne1
- id : fromclient1admin
- pwd : fromclient1admin
Concepts alongside with Timestamp
Detailed Notes: https://github.com/SudirKrishnaaRS/NextJS-14-Blog-App/blob/main/notes/NextJs%20App%20Router%20notes.md
Topics :
- App Router Overview
- Routes
- Nested Routes
- Dynamic Routes
Link :
https://youtu.be/vCOSTG10Y4o?si=3n4CPvRhC5aj7Gpy&t=576
Timestamp :
09:35
![image](https://private-user-images.githubusercontent.com/67383465/345867956-4057e790-fdd2-4074-9e52-48cf4b5bbb96.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxNDQ2ODgsIm5iZiI6MTczOTE0NDM4OCwicGF0aCI6Ii82NzM4MzQ2NS8zNDU4Njc5NTYtNDA1N2U3OTAtZmRkMi00MDc0LTllNTItNDhjZjRiNWJiYjk2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA5VDIzMzk0OFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTc5YjdiMGYxNWEyMzY1MjQ0N2YyOGViYTRjMjk3MThmNmI2ZGQ3MzE0MzQwOGFlMDBmZDQ5OTA0YTU2YzUzMjImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.tcEEsWKRbAzmdu62S-LingJzIVHajwjLe4hsG_JpLRs)
References / Links :
- https://nextjs.org/docs/app/building-your-application/routing/colocation
Topics :
- Layout overview
- Use case: useful to add Header and Footer once and it reflects on all pages.
- `layout.js` or `layout.jsx`
- Layout for a particular route (eg. when you create a `layout.jsx` file inside `blog` folder even your nested routes like `blog/1` would have the common layout which you written in `layout.jsx` file)
Link :
https://youtu.be/vCOSTG10Y4o?si=utHVIGEBXT-rWwnW&t=1130
Timestamp :
18:50 Next.js Layouts Explained
Topics :
- Loading: `loading.jsx`
- Error: `error.jsx`
(NOTE: This should be a client component "use client")
- Not Found : `not-found.jsx`
Link :
https://youtu.be/vCOSTG10Y4o?si=utHVIGEBXT-rWwnW&t=1130
Timestamp :
28:00
Topics :
- CSS Modules
- Usage : Helps in easy development as it generates unique class names thus not causing any overrides in styles.
- Advantages of CSS Modules over normal CSS
Link :
https://youtu.be/vCOSTG10Y4o?si=8Ll6vvfOwY0yJ6z9&t=2152
Timestamp :
35:52
Detailed Notes : https://github.com/SudirKrishnaaRS/next14-starter/blob/main/notes/NextJs%20Image%20Notes.md
Topics :
- Traditional <img/>
- Next.js Image Component
- Using Image Containers
- Handling External Images
- Common Issues:
1) Image not displaying: Ensure the width and height properties are specified.
2) External image blocked: Check that the domain is added in next.config.js.
Link :
https://youtu.be/vCOSTG10Y4o?si=b7l15WJqxRWQVLG2&t=3571
Timestamp :
59:30
Detailed Notes: https://github.com/SudirKrishnaaRS/next14-starter/blob/main/notes/NextJS%20Rendering%20-%20SSR%2CCSR.md
Topics :
- Server Component - default
- Client Component - "use client";
- SSR vs CSR
Link :
https://youtu.be/vCOSTG10Y4o?si=E9MyjsKV9-TuV728&t=6516
Timestamp :
01:48:35
Topics :
- What is Hydration?
- Why Hydration Error
- How to resolve Hydration Error
a) Code Workaround using useState and useEffect to conditionally render JSX only when it's Client side render
Example-
Example-
Example-
Link :
https://youtu.be/vCOSTG10Y4o?si=jfkoS81yIJdGGETn&t=7101
Timestamp :
01:58:20
-
What happens when you wrap your server components with a Client component?
Ans. The children of your Client component would still be a Server Component as it's just a wrapper
Detailed Examples for Client Side Navigations: https://github.com/SudirKrishnaaRS/NextJS-14-Blog-App/blob/main/src/app/navigationtest/page.jsx
Topics :
- Client Side Navigations
- useRouter() : Navigate via code like router.push() ,
replace(""), back(), forward();
- usePathname(): Useful to get the current path name
- useSearchParams(): Useful to get the current query params
- Server Side Navigations
- Params: useful to get the current path name on the server-side components (logged in terminal)
![Screenshot 2024-07-15 at 6 41 33 PM](https://private-user-images.githubusercontent.com/67383465/348719392-359b9e36-d8b9-46be-860f-873dc835ecc6.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxNDQ2ODgsIm5iZiI6MTczOTE0NDM4OCwicGF0aCI6Ii82NzM4MzQ2NS8zNDg3MTkzOTItMzU5YjllMzYtZDhiOS00NmJlLTg2MGYtODczZGM4MzVlY2M2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA5VDIzMzk0OFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTAwZDIwOTYwZDAzZDcyOGVjYzRiMjc3MTI5ZjI4MmM5MTk5N2ExNjRhMGY4MGUzZTNmNTY0ZDVhMDc4MzgwYTYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.GQ9Zn0cVYJpIcb2ug42S_wlEb6v2lWiHORjqng--te8)
![Screenshot 2024-07-15 at 6 42 55 PM](https://private-user-images.githubusercontent.com/67383465/348720070-0dc99e01-2bd0-4000-a261-c44ea70b19a0.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxNDQ2ODgsIm5iZiI6MTczOTE0NDM4OCwicGF0aCI6Ii82NzM4MzQ2NS8zNDg3MjAwNzAtMGRjOTllMDEtMmJkMC00MDAwLWEyNjEtYzQ0ZWE3MGIxOWEwLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA5VDIzMzk0OFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTYxN2MzMzFhM2JjMTkzMzk5NGQ0ZjZiYTM4ZTMyMTY0YjM5NGQ4MDA2NmUxNjA0Zjc4ZjRkMDZhODMzZTk3OGMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.b54Df6cHJ9gcXfP99RBncmoExuqj04rVrIpqmJ37vaA)
Link :
https://youtu.be/vCOSTG10Y4o?si=Sw-h_SHrPWxmfwuO&t=7675
Timestamp :
02:07:55
Detailed Example: https://github.com/SudirKrishnaaRS/NextJS-14-Blog-App/blob/main/src/app/blog/page.jsx
Topics :
- How to do Data Fetching?
- Caching, No caching
- Revalidate the cache periodically
Link :
https://youtu.be/vCOSTG10Y4o?si=T_8iC41snN1oe7yR&t=8246
Timestamp :
02:17:26
Detailed Example: https://github.com/SudirKrishnaaRS/NextJS-14-Blog-App/blob/main/src/app/blog/%5Bslug%5D/page.jsx
Topics :
- Suspense (same as react)
- Useful for showing loading
Link :
https://youtu.be/vCOSTG10Y4o?si=gBIRN65zwRxoc8kP&t=8698
Timestamp :
02:24:58
Topics:
- SEO Basics (Page Title and Description)
- SEO for different pages based on Template
- Dynamic SEO for pages with dynamic (API) data
Link :
https://youtu.be/vCOSTG10Y4o?si=8FmAh_Otp9KInuqI&t=10851
Timestamp :
03:00:51
Topics:
- Server Actions
When to use?
- Is Server Actions a replacement for API ?
Answer : When your application is simple and small it can be a replacement for API but if it has multiple tables and a large schema then API is the best.
NOTE:
- `use server` is mandatory for server actions
- When using server actions the function should always be `async` irrespective of what you do
Simple Example of Server Action and how to use :
Link :
https://youtu.be/vCOSTG10Y4o?si=2vWgcXWipbzEWOA0&t=11157
Timestamp :
03:05:57
Topics:
- API Routes : (filename should be `route.js` under `api` folder)
- How to make dynamic API routes
Example(folder structure) for API routes for our application:
Link :
https://youtu.be/vCOSTG10Y4o?si=9rtGmo2XgUBJm6FM&t=11967
Timestamp :
03:19:27
Topics:
- AuthJS
- Added Sign-in with GitHub (Login)
- Added Logout functionality
Docs :
https://authjs.dev/reference/nextjs#environment-variable-inference
Link :
https://youtu.be/vCOSTG10Y4o?si=YHC-Dcux3OvZvZKz&t=12501
Timestamp :
03:28:21