Where should I place backend logic for next.js?

Viewed 268

Excuse me for my ignorance but I am wondering where should my API logic live, when I am building a Next.js app?

When building SPA + API I usually have two differernt apps: one for API and one for SPA. Should I separate Next.js app from my rest API app as well? In examples I see that they put some logic into api/ folder inside the ./pages/ folder. So, should I write all my backedn logic there? (Should I also write logic for DB connection and other things there as well?) I would be thankful for clarifications.

0 Answers
Related