Can Next.js Handle Backend Development Without External Services?

I really don’t like depending on paid third-party services for basic app features. Every tutorial I watch about Next.js seems to push expensive tools for authentication, databases, file uploads, and other stuff.

I prefer to control my own infrastructure and code instead of paying monthly fees for locked-in services. Has anyone successfully deployed a Next.js application to production using only self-hosted solutions? Maybe running everything on your own VPS?

I was considering combining Express.js with Next.js, but I’m curious if Next.js alone with some npm packages could handle the backend requirements. What’s your experience with this approach?

wait, are you using api routes or setting up a separate backend? what features does your app need? i’ve tried both approaches - the choice depends on how complex you’re going and scaling requirements.

Yes, Next.js can handle full-stack development independently. I’ve maintained a production application on a $20/month VPS for over a year, utilizing Next.js API routes alongside PostgreSQL and Redis. These API routes are effective for handling authentication, file management, and database operations. I employ Prisma for database interactions, NextAuth with custom adapters for authentication, and multer for file uploads. Essentially, Next.js API routes function like serverless functions capable of performing significant backend tasks. While the setup is more complex compared to SaaS solutions, it offers complete control and consistent costs. Performance has been excellent, without the need for external services.

Definitely doable! I’ve been running NextJS fullstack apps on DigitalOcean droplets for years. API routes handle most backend needs, and you can throw in Express middleware when necessary. Just use bcrypt for auth, pg for Postgres, and standard file handling libraries. Way cheaper than SaaS bloat in my opinion.