0.1.0 • Published 2 years ago

infer-next-props-type v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

:no_entry: DEPRECATED The issue this package fixes is not needed anymore if you are using Next.js >= v12.3.2. More Info.

InferNextPropsType

Gets inferred typings for getStaticProps or getServerSideProps.

Install

npm install infer-next-props-type --save-dev

Usage

getStaticProps

import type InferNextPropsType from 'infer-next-props-type'

export function getStaticProps() {
   return {
     props: { foo: 'bar' }
   }
}

export default function Page(props: InferNextPropsType<typeof getStaticProps>) {
  return ...
}

getServerSideProps

import type InferNextPropsType from 'infer-next-props-type'

export function getServerSideProps() {
   return {
     props: { foo: 'bar' }
   }
}

export default function Page(props: InferNextPropsType<typeof getServerSideProps>) {
  return ...
}

Related