send getstaticprops data to other static pages, NextJS

Viewed 775

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)

1 Answers

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

Related