#is it possible to preload data before 'getstaticprops' ? so it becomes avaliable for all routes?

2 messages · Page 1 of 1 (latest)

coral walrus
#

instead of calling an api for every route. is it possible to call an api once, and then all getstaticprops routes can some how access those data?

icy crystal
#

You can write a script that stores the prefetched data into json files and use the json file in getStaticProps. Then you just need to run this script before generating the build.

During the development, if the file is not available, you'd hit the actual api.