Documentation : https://nextjs.org/docs

Video lectures

Database : NEON (https://neon.tech/)

ORM : DRIZZLE (https://orm.drizzle.team/)

1. create app

npx create-next-app@latest projectName

→ all components are server components by default to make them client side use “use client” on top.

→ npm run build for build command & npm run start to excute that dist folder

2. Routing

Screenshot 2024-12-18 at 12.28.06 AM.png

→ known as file based routing system

localhost:3000 → page.tsx of app folder
localhost:3000/about → page.tsx of about folder
localhost:3000/about → page.tsx of about folder

localhost:3000 → page.tsx of app folder localhost:3000/about → page.tsx of about folder localhost:3000/about → page.tsx of about folder

→ similarly the concept of Nested Dynamic Routing comes

catch all segments

{ params } : {params: {slug : string[] }}

Private folders

Routing Metadata (for SEO optimisation)

import {Metadata} from "next";
export const metadata : Metadata = {
	title = "About Codevolution",
	description = 'xyz'
}

Screenshot 2024-12-18 at 2.53.16 AM.png

import {Metadata} from "next";
// typescript shit
type Props = {
	params : {
		productId : string;
	}
}

export const generateMetadata = ({ params } : Props) : Metadata => {
	return {
		title : `Product ${params.productId}`,
		description : `description about Product ${params.productId}`
	}
}
title = {
	absolute : "sankalp",
	default : "notes",
	template : "%s | gupta"
}

nested routing

Screenshot 2024-12-18 at 12.41.51 AM.png

Dynamic Routes

export default function productDetails({ params } : {params: {productId: string }}){
	return (
		<h1>deatils about {params.**productId**}</h1> 
		//params.____ should be same as dynamic folder name
	)
}

404 page

import { notFound } from "next/navigation";

// based on some conditions call notFound() function
if(a>b){
	notFound();
}

File Colocation

Route Groups(for good folder structure)

Layouts(for consistent ui)

Screenshot 2024-12-18 at 1.49.55 AM.png

nested layouts(similar concept, self explanatory)

Screenshot 2024-12-18 at 1.55.11 AM.png

3. Navigation

→ ui navigation(using buttons/links)

import Link from "next/link";
export default function Home(){
	return (
		<Link href='/about'> About </Link> // this pushes new screen on top of our stack
		<Link href='/login' replace> Login </Link> // this replaces top screen with new screen
	)
}