infer-next-props-type
v0.1.0
Published
Gets inferred typings for getStaticProps or getServerSideProps.
Downloads
1,996
Readme
: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
- https://nextjs.org/docs/basic-features/data-fetching