ReasonJun

Next.js : getStaticProps with revalidata (ISR) 본문

Frontend/Next.js

Next.js : getStaticProps with revalidata (ISR)

ReasonJun 2023. 6. 18. 00:48
728x90
import Head from 'next/head';
import { Inter } from 'next/font/google';
import Link from 'next/link';
import { useEffect, useState } from 'react';

const inter = Inter({ subsets: ['latin'] });

export async function getStaticProps() {
  return {
    props: { time: new Date().toISOString() },
  };
}

export default function ISR({ time }) {
  return (
    <>
      <Head>
        <title>Create Next App</title>
        <meta name='description' content='Generated by create next app' />
        <meta name='viewport' content='width=device-width, initial-scale=1' />
        <link rel='icon' href='/favicon.ico' />
      </Head>
      <main>
        <h1>{time}</h1>
      </main>
    </>
  );
}

The data is updated when the page is refreshed.

 

728x90
Comments