Next.js Discord

Discord Forum

How to get a list of all paths which have been statically generated?

Unanswered
Gharial posted this in #help-forum
Open in Discord
GharialOP
(This is for pages directory)

I need to generate a list of all paths which have been statically generated already. The reason for this is for a path revalidation strategy where I only care to revalidate paths which have already been generated.

For example: If I have a CMS which has 1000 pages which are in [...slug], but only 30 of them have been generated, and I add an alert which should show up on all pages, I only want to revalidate the 30 pages which have already been generated. Because the other 970 pages will get the alert if someone visits them later.

Specifically looking for a way to see all of the paths that have been statically generated from something like [...slug].

I know it will write out to .next/server/pages/ but while observing that it looks like only some get written out there while others are still in memory.

Is there a way I can access the memory to see the paths which are still in-memory but haven't been written out to the filesystem? Or maybe there is a better way to do this?

1 Reply

GharialOP
Maybe a better way to do this is to somehow flush the in-memory cache to disk and then read the files in the directory? Not sure how I would do that either though.