How do I make Next App dir only run a function once? (Like getStaticProps)
Hi, I have a function called
getLocalDevURL
, but I can't seem to get it to properly run only once on the server, at build time. I am building an utility to generate a QR code, and for that I need to make getLocalDevURL
run only once.
3 Replies
Btw, this is working. But I do not want for this getLocalDevURL function to run all the time. 🙂
u could make it a part of ur build script in package.json
or if u meant the page build, if ur using pages router getStaticProps should work, else just set the revalidate time to smth ridiculously high
use a variable instead of a function
const localDevUrl = networkInterfaces().Ethernet?.find(whatever);