next.jsbuildstaticwhite-labellinggetstaticprops

White label Next 13 app, get static data at build time?


I’m working in Next 13 and would like to use the new app router for this project.

We are going to have different static data for different customer builds of the app. They aren’t page routes like generateStaticParams would generate, it’s more like a ton of .env data. Strings of text, and booleans to indicate features that are on or off.

Storing it all in an env file is messy. How would you go about this problem? I imagine it’s best to keep this as build time data if possible.

Thanks for any suggestions.

Generate static params can only be used in dynamic pages. I thought I could use this before learning that.


Solution

  • So far, doing a readFileSync in server components seems super quick. May be a viable way to get data where needed.

    In fact, in my route component that is server rendered where I use readFileSync, it is loaded into the route already on build. I looked at the .next directory and the content I loaded on the page is already in the html. So this seems to effectively be getStaticProps for my needs.