DEV Community

Cover image for Why I Choose Next.js + Spring Boot for My Solo SaaS Project
Hsu.J.Huang
Hsu.J.Huang

Posted on • Originally published at Medium

Why I Choose Next.js + Spring Boot for My Solo SaaS Project

Hey Devs 👋

Over the past few months, I’ve been building my solo SaaS project and wanted to share some reflections — especially about the tech stack I chose.

While most indie hackers lean on lightweight setups like Node.js or Python, I decided to take a less-traveled path: combining Next.js and Spring Boot.

Here's why I went with this setup — and what I learned along the way.


1️⃣ Why I Still Used Full-Stack Next.js 🤗

Even though my backend is built with Spring Boot, I still made full use of Next.js’s server actions and full-stack features.

Rather than calling the Spring Boot API directly from the browser, I routed all API calls through Next.js server components.

This approach gave me:

  • ✅ Server-side execution only (no client-side leaks)
  • ✅ Invisible API calls in the browser network tab
  • ✅ No CORS headaches

This helped me build a more unified and secure architecture.

But of course, there’s a tradeoff:

The frontend logic became more complex, and managing cookies/headers required extra attention.

API call flow between Next.js and Spring Boot

(Rough flow of how I handle requests in Next.js + Spring Boot)


2️⃣ Why I Chose Spring Boot 🤔

I’m fluent in both Java and Python, but when building a product I plan to maintain, I leaned toward a strongly typed, structured framework.

Spring Boot stood out for:

  • ✅ Well-defined RESTful APIs
  • ✅ Industry-grade security via Spring Security
  • ✅ Easy integrations with cloud services

It’s not the fastest way to prototype, but the structure forced me to think deeply about architecture and domain modeling.

I also modularized key logic into Spring Boot starters, so I can reuse them in future projects regardless of this product’s outcome.


3️⃣ Pitfalls Along the Way 😵

It wasn’t all smooth sailing. Some surprises:

  • 🍪 Setting cookies from Spring Boot didn’t work
    I had to proxy responses through Next.js API routes to manually set JWT cookies.

  • 🔁 Server-Sent Events (SSE) support is messy in this setup

    Not a dealbreaker, but definitely a constraint to watch out for.


4️⃣ Solo Deployment with Terraform 🧱

I have an AWS SAA cert, but deployment is still... painful 😅

To manage infra cleanly, I used Terraform, which helped me:

  • Keep dev/prod environments consistent
  • Easily destroy and rebuild the stack (save AWS costs)

I ended up putting Fargate tasks in a public subnet, because VPC endpoints were too expensive for my MVP.

Infrastructure Diagram


5️⃣ Final Thoughts ✨

Would I do it again? Mostly yes.

But next time I’d consider simplifying the frontend architecture — especially around auth and API routing.

Still, I’m glad I chose this stack. It gave me deeper experience with both frameworks and left me with reusable modules for future projects.


🚀 I'm building Fenixs, an AI-powered platform for storytellers and filmmakers — helping them go from idea 💡 to script ✍️ to visual layout 🎞️.

Thanks for reading! Would love to hear how others have approached similar stacks or tackled API routing with hybrid architectures like this 🙌

Top comments (0)