Run initialization code once per static page generation #73288
Unanswered
inuwan
asked this question in
App Router
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'd like to run some initialization code once for a static page generation build. The init reads thousands of JSON files from the filesystem and stores the results in a Map. The Map is used by numerous pages and the init is called by each page in its generateStaticParams method. I have a check to see if the Map has data and not reread from the file system. But is seems that Next creates a separate Node process for each page generated (or app route?), so the check doesn't trigger and I reread the thousand of files from the filesystem for each page generated. Is there something similar to instrumentation.ts, used to run code once for a Next server, but for a static page generation build?
Beta Was this translation helpful? Give feedback.
All reactions