MinJeung-Kim / NextJS-v13--Study

Next.js(v13)์˜ ๋ชจ๋“ ๊ฒƒ๐Ÿ˜Ž
https://next-js-v13-study.vercel.app
0 stars 0 forks source link

fetch๋ฅผ ์‚ฌ์šฉํ•œ SSG, ISR, SSR #18

Open MinJeung-Kim opened 1 year ago

MinJeung-Kim commented 1 year ago

๐Ÿ—„๏ธ Server Component

๐Ÿ–๏ธfetch๋ฅผ ์‚ฌ์šฉํ•œ SSG ๋ Œ๋”๋ง

const res = await fetch("https://meowfacts.herokuapp.com");
const data = await res.json();
const factText = data.data[0];
$ npm run build && npm run start

chrome_pz8i9lznfA

๐Ÿ‘‹fetch๋ฅผ ์‚ฌ์šฉํ•œ ISR ๋ Œ๋”๋ง

const res = await fetch("https://meowfacts.herokuapp.com", {
    cache:'reload', 
  });
const data = await res.json();
const factText = data.data[0];

chrome_ZgrZJHOxxN

๐Ÿค™fetch๋ฅผ ์‚ฌ์šฉํ•œ SSR ๋ Œ๋”๋ง

const res = await fetch("https://meowfacts.herokuapp.com", {
    cache:'no-store',
    next: { revalidate: 0 },
  });
const data = await res.json();
const factText = data.data[0];