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)