V1 without presentation styling
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
## Server components [Nextjs docs](https://nextjs.org/docs/app/building-your-application/rendering/server-components)
|
||||
|
||||
## Presentation flow
|
||||
|
||||
0. Comparation between NextJS and React
|
||||
1. Introduction without strategies.
|
||||
2. Benefits.
|
||||
3. Actual process and why its important to know it.
|
||||
@@ -50,24 +52,32 @@ The rendering works is split into chunks:
|
||||
- Streaming: work is split into chunks and streamed as they become ready so the load is progressive.
|
||||
|
||||
### [Fetching data from the server](https://nextjs.org/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating#revalidating-data)
|
||||
To fetch data from the server you only need an `async` component. The data is automatically cached by Next to avoid constant calls to the data source. This means you can omit the cache configuration in your fetch call:
|
||||
|
||||
To fetch data from the server you only need an `async` component. The data is automatically cached by Next to avoid constant calls to the data source. This means you can omit the cache configuration in your fetch call:
|
||||
|
||||
```js
|
||||
// not needed
|
||||
fetch('https:...', { cache: 'force-cache' })
|
||||
// not needed
|
||||
fetch("https:...", { cache: "force-cache" });
|
||||
```
|
||||
|
||||
But you can also revalidate on every request:
|
||||
|
||||
```js
|
||||
fetch('https://...', { cache: 'no-store' })
|
||||
fetch("https://...", { cache: "no-store" });
|
||||
```
|
||||
|
||||
#### Revalidation
|
||||
|
||||
Revalidation is not directly managed but you can force it with:
|
||||
|
||||
- A timer:
|
||||
|
||||
```js
|
||||
fetch('https://...', { next: { revalidate: 3600 } })
|
||||
fetch("https://...", { next: { revalidate: 3600 } });
|
||||
```
|
||||
|
||||
- Manually:
|
||||
|
||||
```js
|
||||
// page.tsx file
|
||||
export default async function Page() {
|
||||
@@ -79,7 +89,7 @@ export default async function Page() {
|
||||
// action.ts file
|
||||
'use server' // cause of the .ts
|
||||
import { revalidateTag } from 'next/cache'
|
||||
|
||||
|
||||
export default async function action() {
|
||||
revalidateTag('collection')
|
||||
}
|
||||
@@ -89,3 +99,8 @@ export default async function action() {
|
||||
## Serverside fetching
|
||||
|
||||
[Different types](https://wallis.dev/blog/nextjs-serverside-data-fetching)
|
||||
|
||||
### GerServerSideProps (async function)
|
||||
|
||||
- Automatic cache
|
||||
- Revalidated either by timeout or forced with tags
|
||||
|
||||
Reference in New Issue
Block a user