Company
Date Published
Author
Cassidy Williams
Word count
546
Language
English
Hacker News points
None

Summary

In Next.js, developers can call APIs at both build time and runtime, each with its own advantages and disadvantages. Calling an API at build time allows for faster page loads but requires updating the content by re-running the build process. On the other hand, calling an API at runtime provides up-to-date data but may slow down user experience. The example demo using NASA Open APIs illustrates both approaches, demonstrating how to use `getStaticProps` for build-time data and React hooks like `useQuery` and `useState` for runtime data. This highlights the flexibility in structuring applications to balance between build time and runtime code execution.