HaNdTriX / infer-next-props-type

Home Page:https://www.npmjs.com/package/infer-next-props-type obsolete

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[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

About

https://www.npmjs.com/package/infer-next-props-type obsolete

License:MIT License


Languages

Language:TypeScript 100.0%