1

im fetching a huge json data from an external API inside my getstaticprops. this data will then be divided into parts to be send to other static pages (hundreds of pages) as props.

// page1.tsx

const page1 = ({ page1Data }) => {
    ...
}

const getStaticProps: GetStaticProps = async () => {
    const res = await fetch('https://hugedata')
    const jsonData = await res.json()
    const { page1Data, page2Data, page300Data, ...allData } = jsonData

    return { props: { page1Data } }
}

i only know how to send the staticprops data to the component inside the file like this.

is there a way send these data to other static pages/routes ? (e.g. to page2.tsx)

juliomalves
  • 42,130
  • 20
  • 150
  • 146
  • Does this answer your question: [Next js nested dynamic routes: data fetching via getstaticprops with shared data between routes](https://stackoverflow.com/questions/66869440/next-js-nested-dynamic-routes-data-fetching-via-getstaticprops-with-shared-data)? You'll have to implement your own solution to cache the data to be shared across page builds. – juliomalves Jan 31 '22 at 11:14

1 Answers1

0

It's not really possible to send data between pages. But you can see the methods described here.

I suggest you really check router and inspect data inside it, you can find a lot of info about data on the page.

P.S. As I see, you are trying to get a lot of data and you need to use pagination and split it to the parts, you can use this lib

illia chill
  • 1,652
  • 7
  • 11