Skip to content
Engineering

Changing the foundation while the house is being built: how Base44 apps went full stack

Collage of abstract app interface fragments: a loading spinner, a grid, an orders heatmap and a Thinking label

TL;DR

New Base44 apps are now full-stack TanStack Start apps instead of Vite single-page apps with separate backend functions. It took a server in every dev sandbox, a Cloudflare-hosted pipeline and a retrained builder agent. Dev server startup failures fell to under 0.1% of new apps.

There's a scene in Indiana Jones where he swaps a golden idol for a bag of sand in one quick move, hoping the temple won't notice. Changing the core stack of a live platform feels a lot like that, except the temple keeps changing too. While I was moving Base44 apps to a new architecture, the rest of the team kept adding features on top of the old one every day.

This post covers how we did it: why we picked TanStack Start, what had to change underneath it, how we retrained the AI agent that writes the apps and what I'd tell any team running a long project inside a fast-moving codebase. The short version: let AI watch your rollout, and don't be afraid to aim straight at the end goal.

What App Infra does

I'm a software engineer on the App Infra team at Base44. Base44 builders describe the app they want, and our builder agent writes it. My team builds the stack that the agent builds inside of.

Every capability we add is a new primitive the agent can reach for: a database, connections to other systems, server-side rendering for websites and more. The more primitives the agent has, the harder the problems builders can take on – without setting up any infrastructure themselves, and without having to move off Base44 once their app needs to serve more people and more traffic.

The problem with single-page apps plus functions

Until recently, every Base44 app was a Vite single-page app. Anything that needed a server lived as serverless backend functions, and each backend function was its own isolated program. That worked, but it had costs:

  • Sharing code between backend functions was awkward, because each one stood alone.
  • Going live meant publishing a static app plus a set of separate programs.
  • Websites built on Base44 had no server-side rendering, which matters for SEO.

We wanted every app to be full stack: one codebase where pages and server code live together and share code, with server-side rendering built in.

First attempt: convert only when needed

We didn't start with a big switch. The first approach was additive and aimed not to rock the boat: apps would still start out as single-page apps, and only when the agent decided an app needed a server would it convert that app to full stack, in place, without rewriting most of it.

We gave it a shot, but quickly learned that it required a heavy investment - for something we planned to replace eventually anyway. We always knew the end goal was building full-stack apps from day one on a single stack. So we decided to go all in: new apps start as TanStack Start apps, and migrating existing single-page apps becomes a separate project for later.

Why TanStack Start

We had a few hard requirements:

  • Built on Vite. We already built every app with Vite, liked how easy it is to build and host and wanted to keep going on top of it.
  • React. Our apps and our agent live in React.
  • Both kinds of apps. Many Base44 apps sit behind a login and behave like single-page apps. Others are public websites that need server-side rendering for SEO. One stack had to handle both.

TanStack Start met all of these requirements. It is a full-stack web framework built for React that provides the infrastructure to build modern full-stack applications while keeping developers in close control of where code runs - whether on the client or the server. Furthermore, TanStack was already part of our stack through React Query, its router is excellent, and it offers server functions and server routes right out of the box.

What had to change underneath

The work split into three parts.

1. A server inside every dev sandbox

We replaced the single-page app's dev server with TanStack Start's server. Soon, though, we ran into an issue: the sandbox environment kept reporting that the dev server had crashed when, in reality, 99% of the time it was running fine. What was going on?

The sandbox checked if the dev server was up by requesting the app's homepage - effectively executing the app's code. But that wasn't the right check. If the app had a bug and threw an exception, the sandbox interpreted that exception as a dev server crash. In reality, only the application running inside the server had crashed, while the dev server itself was fine. The fix was checking Vite's own health ping instead of requesting the app's homepage. Vite's ping simply asks, "Is the web server itself up and responding?" - providing a much more reliable health signal for the sandbox.

2. A new hosting pipeline

The new TanStack Start apps are hosted on Cloudflare Workers for Platforms - the same platform that runs backend functions for single-page apps - which meant the hosting side needed to support both setups. With single-page apps, the user's browser communicated directly with backend functions. But because the new apps run code on the server that also needs to reach the backend, API calls were now coming from Cloudflare itself. These calls had to be routed through a proxy - a middleman layer that verifies caller identity and permissions.

3. Teaching the builder agent a new way to build

The second big challenge wasn't infrastructure at all. Our builder agent knew how to write single-page apps. It had to learn where server code goes, to use the stack's server functions instead of backend functions, and to avoid the traps of server rendering – while still supporting single-page apps, which we'll keep supporting for a long time.

Two areas took the most back-and-forth:

  • Hydration errors. 'Hydration' is the process where JavaScript code is attached to server-rendered HTML so the page becomes interactive. This means the JavaScript runs twice: once on the server to produce the initial HTML, and once in the browser (the client) to produce locally rendered HTML that the JavaScript attaches to. If the server-rendered HTML and locally rendered HTML don't match, hydration fails - triggering an auto-fix round that costs the builder time and credits. The agent's instructions needed to cover any code that could cause differences, like random values and dates.
  • Secure server code. Server code can expose data if it's written carelessly. We added middlewares that make authentication much simpler, and taught the agent to use them, along with row-level and field-level security rules on an app's data. Then we checked that the apps it writes really don't leak.

All of it went through evals, so we could see that nothing regressed and that TanStack apps matched single-page apps before more builders saw them.

Rolling it out behind a flag, watched by an agent

Developing the new feature in a separate git branch could potentially make merging the new code difficult, since the reset of the code kept changing. To counter that, I pushed the new code straight to production behind a 'feature flag': a toggle that allowed me to disable the new code if needed. To watch the rollout, I set up an AI agent that tracks technical and business numbers side by side, tells me when something looks wrong and controls the flag: it can turn it off by itself if something breaks, and it can widen exposure, with my approval, when the data looks good.

That paid off. At one point, a routine dependency update broke server rendering, and most new TanStack apps stopped starting. The agent saw it and turned the flag off. We had the fix live within hours and reopened the rollout. Because only part of new apps were on the flag, the damage stayed contained.

This feature flag approach had another advantage: it allowed me to get feedback from teammates and early builders on real problems instead of lab problems.

Here's where startup reliability ended up. Before the health-check fix, about 4% of new TanStack apps failed to start their dev server. Today it's under 0.1%, lower than the roughly 0.5% we see for single-page apps.

SetupShare of new apps whose dev server fails to start
TanStack Start apps, before the health-check fixAbout 4%
TanStack Start apps, todayUnder 0.1%
Single-page appsAbout 0.5%

Table 1.Dev server startup failures for new apps, according to the author's production figures.

It isn't free. A builder turn on a TanStack app costs slightly more, and we're still working on that. That work never really ends. At some point, though, the benefit to builders is clearly worth it, and that's when you roll out.

The hardest part: a platform that doesn't stop

None of the individual bugs were the hardest part. The hardest part was making a core change while the platform kept moving at full speed. Other engineers needed full-stack support for their new features while I was still building it, and every new feature had to work in both worlds.

That meant staying on top of what was changing across the codebase and keeping close contact with the team, so new work landed in line with the new stack instead of around it.

Key takeaways

  • Use AI to keep up, not only to write code. Repository velocity is now beyond what one person can track. I relied on AI agents that watch the codebase and add support for new features as they appear. On a long project, think in workflows and loops, not single tasks.

  • Give your rollout a monitor that can act. An agent that watches technical and business numbers together, and can turn the flag off without waiting for you, is the difference between an hours-long incident and a long one.

  • Test in production behind a flag. You learn about the real problems early, before you widen exposure, and you avoid a branch that drifts for months.

  • Aim at the end goal. We dropped the in-between conversion path and went straight to full-stack apps. With the speed AI gives a team now, the ambitious plan is often realistic sooner than you'd think.

What's next

There's more coming. We want to make TanStack apps cheaper and faster to build, add more scaffolding so the builder agent can build more complex apps faster and make the apps themselves faster for the people using them.

Go ahead. Build it yourself.

Start building