-
Notifications
You must be signed in to change notification settings - Fork 0
/
notes.txt
16 lines (14 loc) · 1.36 KB
/
notes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Components:
->Client components: used for user interaction/implementing interactivity, and for using React hooks.
->Server components: used for data fetching, as it is more secure and data can be cached when using server components. We cannot use React hooks here.
Routes:
->Each folder is a separate route, and by rules, the page rendered at that route must be named page.js. Each folder/route should have atleast one page.js that renders when you go to that route.
--Nested routes:
->A folder within another folder. Ex: membership inside accounts, makes accounts the parent folder/route. This means to access membership, we need to go to /accounts/membership. And as usual membership folder should also have page.js.
--Dynamic routes:
->A folder names within [], thus telling NextJS that this is a dynamic route.
--Catch all route:
->[...folderName] -> for >1 parameter in dynamic route. Ex: products/1 -> dynamic. products/1/2/3.. -> needs catch all route. Parameters called slugs. Catch all routes can have any number of slugs.
Links:
->Method 1: using Link from 'next/link' -> <Link href={'/pathname'}>some text</Link>. Can be used in both client and server components, but if we want to apply some logic before redirecting the user in server component, we cannot do that using Link.
->Method 2: useRouter from 'next/navigation'. Since it's a hook, works only in client components.