2023-07-05 15:11:16 +02:00
|
|
|
---
|
|
|
|
title: 'Invalid `getStaticProps` Return Value'
|
|
|
|
---
|
2020-02-21 06:45:50 +01:00
|
|
|
|
2023-07-05 15:11:16 +02:00
|
|
|
## Why This Error Occurred
|
2020-02-21 06:45:50 +01:00
|
|
|
|
2020-02-27 18:57:39 +01:00
|
|
|
In one of the page's `getStaticProps` the return value had the incorrect shape.
|
2020-02-21 06:45:50 +01:00
|
|
|
|
2023-07-05 15:11:16 +02:00
|
|
|
## Possible Ways to Fix It
|
2020-02-21 06:45:50 +01:00
|
|
|
|
2020-02-27 18:57:39 +01:00
|
|
|
Make sure to return the following shape from `getStaticProps`:
|
2020-02-21 06:45:50 +01:00
|
|
|
|
2023-07-05 15:11:16 +02:00
|
|
|
```tsx filename="pages/example.tsx"
|
2020-03-01 15:20:28 +01:00
|
|
|
export async function getStaticProps(ctx: {
|
2022-04-05 20:59:58 +02:00
|
|
|
params?: ParsedUrlQuery;
|
|
|
|
preview?: boolean;
|
|
|
|
previewData?: PreviewData;
|
2020-03-01 15:20:28 +01:00
|
|
|
}) {
|
2022-04-05 20:59:58 +02:00
|
|
|
return {
|
|
|
|
props: { [key: string]: any }
|
|
|
|
}
|
2020-02-21 06:45:50 +01:00
|
|
|
}
|
|
|
|
```
|
2022-04-05 20:59:58 +02:00
|
|
|
|
2023-07-05 15:11:16 +02:00
|
|
|
## Useful Links
|
2022-04-05 20:59:58 +02:00
|
|
|
|
2023-07-05 15:11:16 +02:00
|
|
|
- [`getStaticProps` Documentation](/docs/pages/api-reference/functions/get-static-props)
|