generated from sfeir-open-source/sfeir-school-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f47b94f
commit 1280d3f
Showing
30 changed files
with
383 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!-- .slide: class="two-column with-code " --> | ||
|
||
# Rendering methods | ||
|
||
Next.js combines various rendering strategies : | ||
|
||
- dynamic rendering (classic SSR) | ||
- static rendering | ||
- incremental static generation | ||
- streaming | ||
- bonus : partial pre-rendering |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!-- .slide: class="two-column with-code " --> | ||
|
||
<style> | ||
.ssr-workflow-schema-01 { | ||
width: 1200px; | ||
height: auto; | ||
} | ||
</style> | ||
|
||
# Dynamic rendering | ||
|
||
<img src="./assets/images/08-rendering/ssr-workflow-schema.png" class="ssr-workflow-schema-01" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!-- .slide: class="two-column with-code " --> | ||
|
||
# Dynamic rendering | ||
|
||
**Pros** | ||
|
||
- Security | ||
- Performance | ||
- caching | ||
- reducing JavaScript | ||
- Fast First Contentful Paint | ||
- SEO | ||
|
||
##--## | ||
|
||
<br/> <br/> <br/> | ||
|
||
**Cons** | ||
|
||
- Cost | ||
- Scalability |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!-- .slide: class="two-column with-code " --> | ||
|
||
<style> | ||
.static-rendering-20 { | ||
width: 1400px; | ||
height: auto; | ||
} | ||
</style> | ||
|
||
# Static rendering | ||
|
||
_This is the default behavior. If all conditions are set, Next will always prioritize this rendering method_ | ||
|
||
<img src="./assets/images/08-rendering/static-rendering.png" class="static-rendering-20" /> |
25 changes: 25 additions & 0 deletions
25
docs/markdown/08-rendering-methods/21-static-rendering-schema.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!-- .slide: class="two-column with-code " --> | ||
|
||
<style> | ||
.static-rendering-21 { | ||
width: 800px; | ||
height: auto; | ||
} | ||
</style> | ||
|
||
# Static rendering | ||
|
||
## Conditions | ||
|
||
- The route data is not personalized to the user (no dynamic function) | ||
- cookies | ||
- headers | ||
- searchParams props | ||
- The route can be known at build time | ||
- The route data is cached (data cache) | ||
|
||
##--## | ||
|
||
<br/> <br/> <br/> | ||
|
||
<img src="./assets/images/08-rendering/static-rendering-output.png" class="static-rendering-21" /> |
12 changes: 12 additions & 0 deletions
12
docs/markdown/08-rendering-methods/22-static-rendering-config.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!-- .slide: class="two-column with-code " --> | ||
|
||
# Static rendering | ||
|
||
## Configuration | ||
|
||
Static rendering can be configured using [route segment configuration](https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config) | ||
|
||
```js | ||
export const dynamic = 'auto' | 'force-dynamic' | 'error' | 'force-static'; | ||
export const revalidate = false | number; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!-- .slide: class="two-column with-code " --> | ||
|
||
# Incremental Static Rendering | ||
|
||
By default, dynamic routes (_/[id]/page.tsx_) can't be known at build time <br/> | ||
But there is a way to generate them : | ||
|
||
```js | ||
export const generateStaticParams = async () => { | ||
return []; | ||
}; | ||
``` |
18 changes: 18 additions & 0 deletions
18
docs/markdown/08-rendering-methods/31-incremental-schema.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!-- .slide: class="two-column with-code " --> | ||
|
||
<style> | ||
.incremental-31 { | ||
width: 1400px; | ||
height: auto; | ||
} | ||
</style> | ||
|
||
# Incremental Static Rendering | ||
|
||
```js | ||
export const generateStaticParams = async () => { | ||
return [{ id: 1 }, { id: 2 }, { id: 3 }]; | ||
}; | ||
``` | ||
|
||
<img src="./assets/images/08-rendering/incremental.png" class="incremental-31" /> |
41 changes: 41 additions & 0 deletions
41
docs/markdown/08-rendering-methods/32-incremental-example.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<!-- .slide: class="two-column with-code " --> | ||
|
||
# Incremental Static Rendering | ||
|
||
## Examples | ||
|
||
Single dynamic segment | ||
|
||
```js | ||
// /app/employee/[id]/page.tsx | ||
export const generateStaticParams = () => { | ||
return [{ id: '1' }, { id: '2' }, { id: '3' }]; | ||
}; | ||
|
||
// Will generate : | ||
// - /employee/1 | ||
// - /employee/2 | ||
// - /employee/3 | ||
``` | ||
|
||
##--## | ||
|
||
<br/> <br/> | ||
|
||
Multiple dynamic segment | ||
|
||
```js | ||
// /app/employee/[category]/[id]/page.tsx | ||
export const generateStaticParams = () => { | ||
return [ | ||
{ id: '1', category: 'a' }, | ||
{ id: '2', category: 'b' }, | ||
{ id: '3', category: 'c' }, | ||
]; | ||
}; | ||
|
||
// Will generate : | ||
// - /employee/a/1 | ||
// - /employee/b/2 | ||
// - /employee/c/3 | ||
``` |
40 changes: 40 additions & 0 deletions
40
docs/markdown/08-rendering-methods/33-incremental-example2.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<!-- .slide: class="two-column with-code " --> | ||
|
||
# Incremental Static Rendering | ||
|
||
## Examples | ||
|
||
Catch-all dynamic segment | ||
|
||
```js | ||
// /app/employee/[...params]/page.tsx | ||
export const generateStaticParams = () => { | ||
return [{ params: ['a', '1'] }, { params: ['b', '2'] }, { params: ['c', '3'] }]; | ||
}; | ||
|
||
// Will generate : | ||
// - /employee/a/1 | ||
// - /employee/b/2 | ||
// - /employee/c/3 | ||
``` | ||
|
||
##--## | ||
|
||
<br/> <br/> | ||
|
||
Parent / Children page segments : | ||
|
||
```js | ||
// /app/employee/[category]/page.tsx | ||
export const generateStaticParams = () => { | ||
return [{ category: 'a' }, { category: 'b' }, { category: 'c' }]; | ||
}; | ||
``` | ||
|
||
```js | ||
// /app/employee/[category]/[id]/page.tsx | ||
export const generateStaticParams = async ({ params: { category } }) => { | ||
const employees = await getEmployees(category); | ||
return employees.map((employee) => ({ id: employee.id })); | ||
}; | ||
``` |
20 changes: 20 additions & 0 deletions
20
docs/markdown/08-rendering-methods/34-incremental-runtime.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!-- .slide: class="two-column with-code title-margin-sm " --> | ||
|
||
<style> | ||
.incremental-34 { | ||
width: 1350px; | ||
height: auto; | ||
} | ||
</style> | ||
|
||
# Incremental Static Rendering | ||
|
||
What if a page params are not known at build time ? | ||
|
||
<img src="./assets/images/08-rendering/incremental-runtime.png" class="incremental-34" /> | ||
|
||
This behavior can be disabled definig dynamicParams : | ||
|
||
```js | ||
export const dynamicParams = false; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!-- .slide: class="exercice" --> | ||
|
||
# Rendering methods | ||
|
||
## Lab | ||
|
||
<small> | ||
|
||
TODO | ||
|
||
</small> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!-- .slide: class="two-column with-code " --> | ||
|
||
<style> | ||
.ssr-issue-50 { | ||
width: 1450px; | ||
height: auto; | ||
} | ||
</style> | ||
|
||
# Streaming | ||
|
||
## The problem with classic SSR (or dynamic rendering) | ||
|
||
<img src="./assets/images/08-rendering/ssr-issue.png" class="ssr-issue-50" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!-- .slide: class="two-column with-code " --> | ||
|
||
<style> | ||
.ssr-solution-51 { | ||
width: 1500px; | ||
height: auto; | ||
} | ||
</style> | ||
|
||
# Streaming | ||
|
||
## React solution | ||
|
||
<img src="./assets/images/08-rendering/ssr-solution.png" class="ssr-solution-51" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!-- .slide: class="two-column with-code " --> | ||
|
||
# Streaming | ||
|
||
## Next.js implementation | ||
|
||
Two possibilities : | ||
|
||
- using router file convention : **loading.tsx** | ||
- using **<Suspense />** directly |
30 changes: 30 additions & 0 deletions
30
docs/markdown/08-rendering-methods/53-streaming-loading.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<!-- .slide: class="two-column with-code " --> | ||
|
||
<style> | ||
.loading-53 { | ||
width: 450px; | ||
height: auto; | ||
} | ||
</style> | ||
|
||
# Streaming | ||
|
||
## loading.tsx | ||
|
||
Convention : <br/> | ||
Add a **loading.tsx** file and export a component next to the segment you want to stream <br/><br/> | ||
This component will be displayed while the Promises of the child components are pending : | ||
|
||
```jsx | ||
const Loading = () => { | ||
return <p>Loading...</p>; | ||
}; | ||
|
||
export default Loading; | ||
``` | ||
|
||
##--## | ||
|
||
<br/> <br/> <br/> | ||
|
||
<img src="./assets/images/08-rendering/loading.png" class="loading-53" /> |
16 changes: 16 additions & 0 deletions
16
docs/markdown/08-rendering-methods/54-streaming-parallel.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!-- .slide: class="two-column with-code " --> | ||
|
||
<style> | ||
.loading-parallel-54 { | ||
width: 1300px; | ||
height: auto; | ||
} | ||
</style> | ||
|
||
# Streaming | ||
|
||
## loading.tsx | ||
|
||
This is also very interesting with parallel routing : | ||
|
||
<img src="./assets/images/08-rendering/loading-parallel.png" class="loading-parallel-54" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!-- .slide: class="two-column with-code " --> | ||
|
||
# Streaming | ||
|
||
## Suspense | ||
|
||
You can also use React **\<Suspense /\>** API Directly : | ||
|
||
```jsx | ||
import { Suspense } from 'react'; | ||
import { Employees, Expenses } from './Components'; | ||
|
||
export default function Posts() { | ||
return ( | ||
<section> | ||
<Suspense fallback={<p>Loading employees...</p>}> | ||
<Employees /> | ||
</Suspense> | ||
<Suspense fallback={<p>Loading expenses...</p>}> | ||
<Expenses /> | ||
</Suspense> | ||
</section> | ||
); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!-- .slide: class="exercice" --> | ||
|
||
# Streaming | ||
|
||
## Lab | ||
|
||
<small> | ||
|
||
TODO | ||
|
||
</small> |
Oops, something went wrong.