How to do Build Time Computations with Next.js App Router

  Kiến thức lập trình

How do you go about performing computations at build time?

I don’t need to fetch data and that’s all the docs seem to talk about. I just want to do some complex-ish string processing. Ideally, I could avoid doing these every request because that would increase response time.

For example in the old paradigm I could do.

function getStaticProps(){
 const longString= "..."
 const result = process(longString)
 return { data: result }
}

Is there an app router equivalent to this? Bonus points if there’s a way to revalidate/recompute every x seconds

LEAVE A COMMENT