0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

速習App Router#2 SSR・CSR・ISR

Last updated at Posted at 2024-02-27

はじめに

この記事は下記の講座で学んだ内容をまとめています。
理解が怪しい所があるので教えてくれるととても嬉しいです。

目次

1.速習App Router#1
2.速習App Router#2 <- この記事
3.速習App Router#3
4.速習App Router#4
5.速習App Router#5
6.速習App Router#6
7.速習App Router#7

App RouterでのSSR・CSR・ISR

Pages RouterではgetServerSidePropsgetStaticPropsを使ってレンダリングを決めていたが、App Routerではfetchに渡すオプションを使ってレンダリング方式を決める。

fetchに渡すオプションには
・{ cache: "force-cache" }
・{ cache: "no-store" }
・{ next: { revalidate: 10 }}
が存在する。
・{ cache: "force-cache" } は SSR
・{ cache: "no-store" } は SSG
・{ next: { revalidate: 10 }} は ISR
を意味する。

使う時はコンポーネントの中でfetchを実行し、オプションを渡す

    const res = await fetch(`${process.env.url}/rest/v1/notes?select=*`, {
        headers: new Headers({
            apikey: process.env.apikey as string
        }),
        cache: "no-store"
    });

さいごに

SSRとRSCの違いがあまり分かっていない分かりやすく説明出来る方教えていただけたらとても嬉しいです。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?