Next.js Discord

Discord Forum

Can generateStaticParams be used to statically build api responses of app router api route handlers?

Unanswered
Schneider’s Smooth-fronted Caima… posted this in #help-forum
Open in Discord
Schneider’s Smooth-fronted CaimanOP
I have an API route that returns 100 permutations of a simple picture of a dog. I want to generate those permutations of the dog at build time rather than at runtime to improve performance and reduce the cost of doing this in production when a user requests them.

Can generateStaticParams be used in the app router to do this?

My route is /api/dog/[color]/route.tsx
And I have set dynamic to force-static.

I am running v14 of NextJS. When I build it says the route is static, but the size is 0kbs, so I’m not sure it is working as I would expect it to.

1 Reply

Schneider’s Smooth-fronted CaimanOP
It looks like what I want to do isn’t possible. https://github.com/vercel/next.js/discussions/56829