Best Practices for Structuring the /api folder in Next.js

While we all have our preferred methods for organizing Next.js projects, I haven't been able to find a comprehensive guide specifically focused on structuring the /pages/api folder and keeping API-side code well-organized This might be because many of us come from a frontend background and approach the /api folder with a "make it work" mentality. Would love to hear your thoughts on how you structure your /pages/api folder in your Next.js projects. Are there any recommended practices or design patterns you've found that have streamlined your API development workflow? For example, do you group related API routes into subfolders? How do you handle middleware or shared logic across API routes? What are some great guides (similar to bulletproof-react) or repositories that I can refer? Thanks in advance for sharing your expertise!
1 Reply
Tim
Tim5mo ago
I been wondering that too. But I have found this github repo: https://github.com/wednesday-solutions/next-bulletproof-ts
GitHub
GitHub - wednesday-solutions/next-bulletproof-ts
Contribute to wednesday-solutions/next-bulletproof-ts development by creating an account on GitHub.
Want results from more Discord servers?
Add your server