Ask Your Question
2

Is it not possible to export data using getStaticProps() in Nextjs?

asked 2023-07-18 03:07:02 +0000

plato gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2023-07-18 03:36:01 +0000

devzero gravatar image

No, it is not possible to export data using getStaticProps() in Next.js as it is a function that runs at build-time and cannot be executed on the client-side. Its main purpose is to pre-render the page with the data fetched from an external API or database. However, you can use getServerSideProps() or client-side fetching using useEffect() or useState() hook to export data.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-07-18 03:07:02 +0000

Seen: 14 times

Last updated: Jul 18 '23