All articles

Software Engineering

Why I'm Moving Away from Next.js as My Default Full-Stack Framework

Why I'm adopting a specialized architecture with Astro, TanStack Start, NestJS, and Go, and how AI is changing the way I approach software development.

Ahmed Reda9 min read
A Next.js block splitting into Astro, TanStack Start, NestJS, and Go modules on a shared platform

I've been using Next.js for years to build full-stack applications, and I still think it's a great framework. It's capable of handling much more than people sometimes give it credit for.

But recently, I decided to take a different approach to building applications, which I'm also adopting in my latest project:

  • Astro for landing pages and marketing websites.
  • TanStack Start for dashboards and internal applications.
  • NestJS for the backend.
  • Go for specific workloads where performance and high concurrency matter.
  • A monorepo to bring everything together.

The decision is mainly about architecture, maintainability, performance, and choosing the right tool for each part of the application.

The previous Next.js application contained the marketing website, dashboard, and backend. In the new monorepo, the Astro marketing website and TanStack Start dashboard talk to the NestJS backend, which can communicate with Go services. Shared packages hold contracts, UI, utilities, and tooling.
Separate responsibilities, unified development environment.

Astro for landing pages and marketing websites

A marketing website and a dashboard have fundamentally different requirements.

Marketing websites are mostly about presenting content, loading quickly, providing a good mobile experience, and being accessible to search engines.

They don't necessarily need the same amount of client-side JavaScript as an interactive web application.

This is where Astro makes a lot of sense to me.

One of my favorite things about Astro is its Islands Architecture. Instead of making the entire page interactive, Astro allows individual components to be hydrated independently.

Example marketing page with static navigation, hero, product features, testimonials, and footer. The pricing calculator between product features and testimonials is the only hydrated component.
Client-side JavaScript is loaded only for components that require hydration.

Imagine a landing page containing a hero section, product features, testimonials, and an interactive pricing calculator.

Most of the page can remain static HTML, while the pricing calculator is hydrated as an independent React component.

This can result in:

  • Less JavaScript delivered to the browser.
  • Less hydration work.
  • Better initial loading performance.
  • More control over when components become interactive.

Astro also allows me to continue using React components wherever interactivity is required.

Next.js is perfectly capable of building fast, SEO-friendly websites. I simply prefer Astro's content-first approach for this type of application.

TanStack Start for dashboards and internal applications

Dashboards are a different story.

Users are constantly navigating between pages, filtering tables, submitting forms, updating records, and interacting with server data.

For these applications, I care more about predictable routing, type safety, data synchronization, and having control over how the application behaves.

That's where the TanStack ecosystem becomes particularly interesting.

TanStack Router provides strongly typed routing, including route parameters, navigation, and URL search parameters.

For example, a dashboard might have a URL like:

/customers?page=2&status=active&sort=createdAt

Having typed and validated search parameters makes managing filters, pagination, sorting, and shareable views much easier.

TanStack Query provides a structured way to manage server state through data fetching, caching, background refetching, request deduplication, optimistic updates, and cache invalidation.

User interaction flows through TanStack Router to the React interface. The interface exchanges data with the TanStack Query cache, which exchanges data with the NestJS API. Query handles fetching, caching, mutations, and invalidation.
Typed navigation and explicit server-state management.

Instead of manually managing loading states and synchronizing data throughout the application, I can rely on a consistent data-fetching model.

TanStack Start brings this ecosystem together with server-side rendering, streaming, server functions, and flexible rendering strategies.

Although TanStack Start is itself a full-stack framework, my preference is to use it primarily for the frontend and keep core business logic in a dedicated backend.

Many of these capabilities are also available when using Next.js with TanStack libraries.

The difference for me is the development model and the level of explicit control I have over routing, caching, and application behavior.

NestJS for the backend

This is probably the most important part of my architectural decision.

Next.js Route Handlers are perfectly capable of serving APIs. For many applications, they're all you need.

However, as backend requirements grow, having a consistent architecture becomes increasingly important.

Think about an application that needs to manage organizations, permissions, subscriptions, payments, webhooks, background jobs, and third-party integrations.

All of this can be implemented in Next.js, but NestJS provides a more structured foundation for organizing these responsibilities.

Incoming HTTP requests flow through guards, pipes, and interceptors into one NestJS app with Authentication, Organizations, Billing, Payments, Analytics, and Integrations modules. The app connects to a database and external services.
Clear business-domain boundaries within a modular monolith.

NestJS allows me to organize the backend around modules, each responsible for a particular business domain.

Its architecture provides:

  • Controllers for handling incoming requests.
  • Services and providers for application logic.
  • Dependency injection for managing dependencies and improving testability.
  • Guards for authentication and authorization.
  • Pipes for validation and transformation.
  • Interceptors for cross-cutting concerns.
  • Exception filters for consistent error handling.

It also makes it easier to introduce architectural patterns such as modular monoliths, Clean Architecture, Domain-Driven Design, CQRS, and event-driven architecture when necessary.

I'm not suggesting that every application needs these patterns. What I value is having a foundation that makes introducing them easier when the requirements justify it.

Another advantage is that the backend becomes independent of the frontend.

If I eventually need to introduce a mobile application, a public API, or another frontend, the core business logic already lives within a dedicated backend.

What about API performance?

Architecture is my primary reason for choosing NestJS, but performance is also worth discussing.

There is no universal number of requests per second that Next.js or NestJS can handle. Performance depends on hardware, runtime, deployment configuration, endpoint complexity, and many other factors.

However, lightweight API benchmarks can help illustrate differences in framework overhead.

A previously referenced NiharDaily benchmark compared Next.js Route Handlers with NestJS using Express and Fastify.

The reported results were:

HTTP API throughput on a scale from 0 to 50,000 requests per second. Next.js Route Handlers: 4,261, the baseline. NestJS with Express: 12,333, or 2.9 times the baseline. NestJS with Fastify: 45,863, or 10.8 times the baseline.
Reported throughput from a lightweight API benchmark, not production capacity.
ImplementationRequests/secMedian latencyP99 latency
Next.js Route Handlers4,26110–11 ms21–22 ms
NestJS + Express12,3333 ms7–8 ms
NestJS + Fastify45,8631 ms2 ms

Based on these reported figures, NestJS with Express achieved approximately 2.9 times the throughput of Next.js, while NestJS with Fastify achieved approximately 10.8 times its throughput.

To put those numbers into perspective:

ImplementationRequests/minRequests/hour
Next.js255,66015.34M
NestJS + Express739,98044.40M
NestJS + Fastify2.75M165.11M

These conversions are theoretical extrapolations, not measured production capacity.

There is also an important difference between throughput, latency, and concurrency.

Throughput measures how many requests a system completes per second. Latency measures how long an individual request takes. Concurrency describes how many requests are in progress simultaneously.

Handling thousands of requests per second does not necessarily mean handling thousands of simultaneous users, and neither metric guarantees that the application will remain responsive under sustained load.

Real-world applications involve authentication, database queries, business logic, external integrations, and network communication.

If most of a request's execution time is spent waiting for a database, reducing framework overhead may not significantly improve the overall response time.

Separating the frontend and backend can also introduce an additional network request where a full-stack Next.js application could previously access data directly within the same process.

A faster API does not automatically mean a faster overall application.

Even the reported Next.js throughput represents a substantial number of requests. I don't consider performance alone a sufficient reason to move away from it.

Source: NestJS vs Next.js API benchmark.

Go for specific performance-critical workloads

I'm not planning to replace my entire TypeScript backend with Go.

Instead, I want the flexibility to introduce Go when a particular workload would benefit from it.

Node.js is excellent for I/O-heavy applications. Its asynchronous execution model allows it to handle many concurrent operations efficiently.

However, CPU-intensive synchronous operations can block the JavaScript event loop unless the work is appropriately isolated.

Go approaches concurrency differently through goroutines, lightweight execution units managed by the Go runtime.

Goroutines can be scheduled across multiple operating system threads, making concurrent and parallel processing relatively straightforward.

On the Node.js side, incoming requests proceed through the JavaScript event loop and asynchronous I/O to responses. On the Go side, incoming requests proceed through goroutines, the Go runtime scheduler, and OS threads to responses.
Different execution models for managing concurrent workloads.

This makes Go an interesting option for workloads such as:

  • High-frequency event collection.
  • Analytics ingestion.
  • Concurrent background processing.
  • Large-scale data synchronization.
  • CPU-intensive data processing.

Go vs Next.js under concurrent load

An independent open-source benchmark using k6 tested lightweight JSON endpoints for 30 seconds with 1,000 virtual users, using Docker containers on an Apple Silicon development machine.

Here are the reported results for Go and Next.js 14:

Two charts show Next.js API at 3,376 requests per second and 295 milliseconds average response time, and Go at 28,597 requests per second and 35 milliseconds. Higher throughput and lower response times are better.
A separate k6 benchmark using 1,000 virtual users and lightweight JSON endpoints.
ImplementationRequests/secAverage response time
Next.js API3,376295 ms
Go (net/http)28,59735 ms

In this particular test, Go delivered approximately 8.5 times the throughput of the tested Next.js implementation, with around 88% lower average latency.

These results come from a different benchmark environment than the previous comparison and should not be combined into a single framework ranking.

They also don't mean that rewriting every backend operation in Go will make it eight times faster.

Database performance, external dependencies, application design, and the nature of the workload still matter.

For me, Go is an additional tool I can introduce when there is a genuine technical reason, while keeping NestJS responsible for most of the application's backend logic.

Source: k6 Backend Framework Benchmark — methodology, results, and source code.

Bringing everything together with a monorepo

One of the greatest benefits of using Next.js as a full-stack framework is having everything in one place.

I don't want to lose that advantage simply because I'm separating the applications.

That's where a monorepo comes in.

The project directory contains apps, services, packages, and infrastructure. Apps contains website (Astro), dashboard (TanStack Start), and api (NestJS). Services contains event-processing (Go). Packages contains contracts, ui, validation, utils, and config.
Independent applications, shared contracts, and a unified workspace.

The marketing website, dashboard, backend, and Go services can all live within the same repository while remaining independent applications.

This allows me to share:

  • API contracts and TypeScript types.
  • Validation schemas.
  • Reusable UI components.
  • Design tokens and utilities.
  • Development configurations and tooling.

It also makes changes that affect multiple applications easier to manage.

For example, if I introduce a new API field, I can update the backend, shared contract, frontend, and relevant tests within the same pull request.

At the same time, each application can have its own build, deployment, and scaling strategy.

The marketing website doesn't need to be redeployed every time the backend changes, and a Go service can be scaled independently when necessary.

A monorepo doesn't mean everything should depend on everything else. Maintaining clear boundaries between applications and shared packages is still essential.

I get the benefits of separating responsibilities without the overhead of managing multiple repositories.

AI is changing how I think about architecture

Another reason behind this decision is AI.

Writing code is becoming one of the cheapest parts of building software.

One of the traditional advantages of full-stack frameworks was reducing the amount of code, configuration, and boilerplate developers needed to write.

That was a very convincing argument, especially when working independently or with a small team.

But AI-assisted development is changing that equation.

Setting up separate applications, implementing architectural patterns, generating typed API clients, writing tests, and maintaining shared packages now require less manual implementation effort.

A monorepo makes this particularly interesting because AI coding tools can work across the frontend, backend, shared contracts, and tests within the same workspace.

I'm no longer as concerned about how much boilerplate a particular architecture requires.

I'm more concerned about whether the architecture is appropriate for the product, how maintainable it will be, and whether it will support future requirements.

Of course, AI doesn't eliminate the complexity of distributed systems, security, deployments, or software maintenance.

Introducing unnecessary technologies is still a bad architectural decision.

But I don't want to compromise on architecture just to write less code.

Final thoughts

This doesn't mean I'll stop using Next.js.

It's still a great choice for many applications, especially when the benefits of having everything within a single framework outweigh the benefits of separating responsibilities.

My decision is simply to stop treating it as the default answer for every new project.

Astro gives me a content-first approach for marketing websites. TanStack Start gives me the frontend development model I prefer for dashboards. NestJS provides a structured backend, and Go gives me an option for specialized workloads.

A monorepo allows me to bring everything together without losing a unified development experience.

As AI makes implementation easier, I think choosing the right architecture becomes even more important.

One framework can handle everything.

That doesn't necessarily mean it should.

Ahmed Reda