A framework decision is not an identity statement. It is a way to reduce the most expensive risks in a specific product—and to decide which risks the team is prepared to own.
For this application, I chose TanStack Start with TanStack Router and TanStack Query. The goal was a useful server-rendered first response, responsive client workflows, and one typed path from route data to the backend contract. This is a fit for this system, not a claim that TanStack Start is universally better than Next.js.
The problem I was solving#
The product combines public pages with authenticated settings, team administration, subscriptions, a watchlist, and S3 file handling. Four constraints shaped the decision:
- ▸Useful first load: a direct visit to a private route should establish the session and render meaningful data, not wait for JavaScript to boot and then start every critical request.
- ▸Responsive interaction: search, forms, dialogs, and mutation feedback should remain client-side and feel immediate after the page is usable.
- ▸Contract alignment: the backend owns the API contract; frontend request and response types should be generated from it instead of drifting through handwritten duplicates.
- ▸Operational choice: local development and CI should have a short feedback loop, and deployment should fit the business environment rather than dictate it.
That led to a practical split: SSR for the initial response and route-critical data; CSR for interaction, local state, and subsequent navigation. Neither rendering mode is a performance guarantee by itself. The route must fetch only what it needs, and the client bundle still needs to be measured.
Why TanStack Start for this application#
1. Routes and data share a clear model#
TanStack Start is built on TanStack Router. Route definitions, nested layouts, loaders, search parameters, and navigation use one type-safe routing model. With shared query options, the responsibilities are visible:
- ▸The route loader declares the data needed for the first screen.
- ▸The component consumes the same query contract.
- ▸A mutation invalidates the cache entries it actually changes.
That makes data ownership easier to trace and review. Next.js App Router is a strong alternative, with Server Components by default and Client Components at interaction boundaries. I preferred explicit Router loaders and the shared query cache for this codebase. A team invested in RSC, existing Next.js infrastructure, or Next’s broader ecosystem may reasonably choose differently. TanStack Start overview · Next.js Server and Client Components
2. Vite supports a fast feedback loop; measure the actual build#
The Vite-based toolchain gives the project familiar development tooling and fast hot updates. That can shorten the feedback loop for frontend engineers and CI. Build time is not vanity: the cost repeats across pull requests, hotfixes, and rollbacks, so I would track cold and warm CI builds and dev startup on this repository instead of publishing a generic percentage.
A smaller or faster production build is not automatic just because the app uses Vite. Route-level code splitting, dependency choices, and production output determine the result. I would compare the emitted client bundle and route-level JavaScript before claiming a size or speed improvement.
3. The ecosystem fits the problems we have#
Router and Query give us typed navigation, route data, caching, and invalidation; React and TypeScript remain the component and contract foundations. The wider TanStack ecosystem also offers focused libraries for forms, tables, virtualization, and developer tools when a feature needs them. That gives teams useful building blocks without requiring every screen to adopt every package. Next.js has a larger ecosystem and community, which is a real advantage for hiring, integrations, and examples. The right ecosystem is the one that reduces friction for this team’s actual work.
4. Deployment remains an explicit engineering choice#
This project uses Nitro in its Vite configuration, giving us a path to choose deployment presets. That is useful flexibility, but it does not prove that every runtime is compatible without changes: the selected adapter, server APIs, and features still need validation. Next.js can also be self-hosted, including in Node or Docker deployments. I chose a deployment setup that keeps portability in view, while treating each target as something to build and verify. TanStack hosting guide · Next.js deployment
Architecture: boundaries around change#
I kept the application a modular monolith. Domains such as auth, settings, subscription, watchlist, and file handling live in feature modules. Routes compose those capabilities; they do not own every transport and business detail. This creates clear seams while avoiding the operational cost of microservices before independent scaling or deployment requires them.
The data path:
Browser route and feature UI → Router loader and shared query options → Feature server function → serverFetch and generated OpenAPI contract → Backend API
- ▸Private routes check the session before entering the authenticated layout and load the data needed for the first screen.
- ▸Feature server modules own domain operations and call the backend through serverFetch.
- ▸serverFetch and session utilities centralize URL resolution, cookie forwarding, response parsing, errors, and session handling. Credentials stay on the server path.
- ▸Generated OpenAPI types and endpoint keys connect frontend calls to the backend contract. They surface many shape mismatches during type-checking; runtime validation and backend authorization still matter.
- ▸fetchSSRQuery and shared query options keep loader behavior aligned with the client cache.
- ▸useAppQuery and useAppMutation apply shared error feedback, session-expiry handling, redirects, and invalidation policy.
This is not SSR everywhere. Loaders should await data required for a useful first render; optional or interaction-triggered data can load later. Client navigation can reuse cached state according to freshness rules. Invalidating only affected query keys avoids unrelated refetches and makes ownership clearer.
SSR detail I would verify before claiming: the inspected code uses route-level ensureQueryData and a QueryClientProvider; I did not find the current Router–Query SSR integration setup in the files reviewed. A loader prefetch alone does not prove dehydration, hydration, per-request cache isolation, or the absence of duplicate browser requests. TanStack documents an SSR integration for these concerns. I would verify hydration and concurrent authenticated request isolation before describing them as achieved. TanStack Query with Start
SOLID, applied pragmatically#
- ▸Single Responsibility: routes coordinate access and loading; feature server modules own domain operations; shared utilities own transport and sessions; views own rendering and interaction.
- ▸Open/Closed: add capabilities through feature modules and generated contracts. Shared query policies are changed once. Static status and filter configuration lives in one feature constants source.
- ▸Liskov Substitution: favor small typed contracts and composition, so a component can work with any valid implementation of the data or action contract.
- ▸Interface Segregation: pass a component only the data and actions it needs instead of threading a broad application object through the view tree.
- ▸Dependency Inversion: UI depends on feature APIs and app hooks, not handwritten HTTP details. serverFetch and generated contracts form the server boundary. A repository or DI container earns its place only when it removes real coupling.
Reuse patterns that earn their complexity#
- ▸Feature modules / vertical slices: keep server functions, schemas, views, and components near the domain that changes them.
- ▸Adapter: serverFetch adapts backend HTTP, cookies, and errors to application conventions; generated keys prevent hand-maintained endpoint strings.
- ▸Facade / policy wrapper: app query and mutation hooks provide a consistent entry point for shared cache and error behavior.
- ▸Composition over inheritance: build layouts, forms, dialogs, and screens from small components and design-system primitives.
- ▸Loader plus query cache: make first-render requirements explicit while supporting reuse and background freshness.
- ▸Single-source configuration: derive status labels, filters, and presentations from feature configuration to prevent drift.
I use these patterns where multiple consumers share a stable reason to change. Factories, generic repositories, or global state for every feature would add APIs for the team to learn without necessarily reducing coupling.
Impact across the team#
- ▸Frontend: typed routes and query contracts make data flow easier to find; shared hooks and components reduce repeated interaction and error-handling work.
- ▸Backend: generated contracts make API shape changes visible to frontend type-checking and review.
- ▸QA: consistent loading, empty, error, and expired-session behavior gives test scenarios clearer boundaries.
- ▸DevOps: a server build with deployment configuration keeps target selection explicit; each production runtime still gets compatibility checks.
- ▸Product: SSR can make meaningful content available earlier on direct navigation, while CSR supports responsive workflows. Real user metrics decide whether that benefit is realized.
These are architecture benefits and intended outcomes, not benchmark results. I would measure LCP and time to useful content on key routes, server TTFB and backend waterfalls, hydration errors and duplicate requests, client bundle size, CI build time, dev startup, and concurrent-request data isolation. Those results show where to optimize next.
Tradeoffs and the decision principle#
TanStack Start has a smaller community and fewer engineers already familiar with it than Next.js. That can mean more onboarding and fewer ready-made answers. SSR also adds server execution, request-context, and hydration responsibilities. It cannot compensate for a slow backend or an oversized client bundle. Route protection improves the user flow; backend authorization remains the security boundary.
The principle is to put each responsibility where its lifecycle and security needs belong: trusted access and first-render data on the server, interaction and local presentation state in the browser, and a typed feature boundary between them. TanStack Start made those boundaries clear for this product. A different product or team may make a different choice.
