nextjs - page model (not app) when you need to create load-able page, you need to be creating folder and name it index.tsx

 

Example code that works


import type { InferGetServerSidePropsType, GetServerSideProps } from 'next';

type Repo = {
  name: string
  stargazers_count: number
}

export const getServerSideProps: GetServerSideProps<{
  repo: Repo
}> = async () => {
 
  console.log("executing getServerSideProps");
  const res = await fetch('https://api.github.com/repos/vercel/next.js')
  const repo = await res.json()
  console.log(repo);
  return { props: { repo } }
}

export default function Page({
    repo
  }: InferGetServerSidePropsType<typeof getServerSideProps>) {
 
    return (
     <>
     <p> hello there</p>
     </>
    )
}

Comments

Popular posts from this blog

The specified initialization vector (IV) does not match the block size for this algorithm