You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+37-1Lines changed: 37 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -77,7 +77,43 @@ It is the best tutorial series on Next.js by far and is over 70 videos long.
77
77
78
78
---
79
79
80
-
### Original Next.js README info
80
+
## Supplemental Notes
81
+
82
+
### Difference between rendering methods in React and Next
83
+
84
+
By default, Next JS pre-renders every page in the application. This means that it generates HTML for each page in advance insead of having it all done by client-side JavaScript
85
+
86
+
In a React app, the JavaScript is loaded which then executes to load the HTMl elements onto the DOM. We just have a div tag with Id tag equal to root. Once the javascript for the page is loaded, it will exceute in the browser, create the different DOM nodes and mount them onto the root div element. This process is called Hydration.
87
+
88
+
In a Next app, the pages are pre-rendered automatically by default, meaning the HTML is already generated with the necessary data and then sent to the browser. The JS then loads and makes the page interactive.
89
+
90
+
### Why pre-render?
91
+
92
+
1. Pre-rendering improves performance
93
+
1. In a react app, you need to wait for the JavaScript to be executed
94
+
2. Perhaps fetch data from an external API and then render the UI
95
+
3. There is a lag time for the user
96
+
4. With a pre-rendered page, the HTMl is already generated and loads faster
97
+
2. Pre-rendering helps with SEO
98
+
1. This isn't as big of an issue with sites that are built behind a login screen, but if you're building something like a blog or an e-commerce site, then SEO is a concern.
99
+
2. With a react app, if the search engine hits your page, it only sees a div tag with id equal to root.
100
+
3. If search engines hit a pre-rendered page, all the content is present in the source code which will help with crawlers that are indexing the page.
101
+
4. If SEO is of concern for app, then pre-rendering is what you want
102
+
103
+
### Pre-Rendering in Next JS
104
+
105
+
NextJs supports two forms of pre-rendering
106
+
107
+
1. Static Generation - Done by default in Next apps when we build for production
108
+
1. Static generation is a method of pre-rendering where the HTMl pages are generated at buildtime
109
+
2. The HTML with all the dats that makesup the content of the web page are gnerwated in advance when you build your applicaiton
110
+
3. Pages can be built once, cahced by a CDN and served to the client almost instantly
111
+
4. Great for blogs, e-commerce, product pages, documentation, and marketing pages
112
+
2. Server-side Rendersing
113
+
114
+
---
115
+
116
+
#### Original Next.js README info
81
117
82
118
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
Copy file name to clipboardExpand all lines: pages/index.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -38,7 +38,7 @@ Next.js uses a file based routing system.
38
38
39
39
- Catch All Routes - add three dots (like a spread operator) inside square brackets to create a catch all route. They're helpful if you want different URLs for the same page layout or even when you're working with pages where some of the route parameters are optional.
40
40
41
-
To navigate to other routes (pages), we wrap the heading for those pages in a Link (capital 'L') component and have the href point to the corresponding internal page via '/PAGE'
41
+
To navigate to other routes (pages), we wrap the heading for those pages in a Link (capital 'L' to distinguish from plain HTMl and JavsScript) component and have the href point to the corresponding internal page via '/PAGE'
42
42
43
43
Place Order Button: first, we add the button and give it a click handler. Next, we define the handler through a const. Within, the order body, we're assuming the order was placed successfully and log 'placing your order'. Then, the user should be programmatically navigated to the products page.
0 commit comments