2023-07-05 15:11:16 +02:00
---
title: '`getStaticProps` / `getServerSideProps` can not be attached to the page component'
---
2020-04-04 01:08:17 +02:00
2023-07-05 15:11:16 +02:00
## Why This Error Occurred
2020-04-04 01:08:17 +02:00
On one of your page's components you attached either `getStaticProps`, `getStaticPaths`, or `getServerSideProps` as a member instead of as a separate export.
These methods can not be attached in the same way as `getInitialProps` and must be their own export
2023-07-05 15:11:16 +02:00
## Possible Ways to Fix It
2020-04-04 01:08:17 +02:00
Move the method to it's own export from your page.
**Before**
2023-07-05 15:11:16 +02:00
```jsx filename="pages/index.js"
2020-04-04 01:08:17 +02:00
function Page(props) {
return <p>hello world</p>
}
Page.getStaticProps = () => ({
props: {
hello: 'world',
},
})
export default Page
```
**After**
2023-07-05 15:11:16 +02:00
```jsx filename="pages/index.js"
2020-04-04 01:08:17 +02:00
function Page(props) {
return <p>hello world</p>
}
export default Page
export const getStaticProps = () => ({
props: {
hello: 'world',
},
})
```
2023-07-05 15:11:16 +02:00
## Useful Links
2020-04-04 01:08:17 +02:00
2023-07-05 15:11:16 +02:00
- [Data Fetching Docs](/docs/pages/building-your-application/data-fetching)