anomalyco/sst · error · VisibleError

No AWS-Lambda preset detected for TanStack Start. Add the n

Error message

No AWS-Lambda preset detected for TanStack Start.

Add the nitro preset to your `vite.config.ts`:
  // vite.config.ts
  import { nitro } from "nitro/vite"

  export default defineConfig({
    server: {
      preset: "aws-lambda",
    },
  });

Detected preset: "${nitro.preset ?? "undefined"}"

What it means

SST's `TanStackStart` component deploys the app as a Nitro AWS Lambda function, so the build output (`.output/nitro.json`) must report the `aws-lambda` preset. In `buildPlan` (platform/src/components/aws/tan-stack-start.ts:359), when the detected preset differs and the project root contains a `vite.config.ts`/`vite.config.js` (Nitro/Vite-style project), SST throws this VisibleError telling you to set the preset in `vite.config.ts`.

Source

Thrown at platform/src/components/aws/tan-stack-start.ts:375

  protected normalizeBuildCommand() { }

  protected buildPlan(outputPath: Output<string>): Output<Plan> {
    return outputPath.apply((outputPath) => {
      const nitro = JSON.parse(
        fs.readFileSync(
          path.join(outputPath, ".output", "nitro.json"),
          "utf-8",
        ),
      );

      if (!["aws-lambda"].includes(nitro.preset)) {
        const projectRoot = path.dirname(outputPath);
        const isViteProject =
          fs.existsSync(path.join(projectRoot, "vite.config.ts")) ||
          fs.existsSync(path.join(projectRoot, "vite.config.js"));

        if (isViteProject) {
          throw new VisibleError(
            [
              "No AWS-Lambda preset detected for TanStack Start.",
              "",
              "Add the nitro preset to your `vite.config.ts`:",
              "  // vite.config.ts",
              '  import { nitro } from "nitro/vite"',
              "",
              "  export default defineConfig({",
              "    plugins: [nitro(), tanstackStart(), ...],",
              "    nitro: {",
              '      preset: "aws-lambda",',
              "      awsLambda: { streaming: true }, // optional",
              "    },",
              "  });",
              "",
              `Detected preset: "${nitro.preset ?? "undefined"}"`,
            ].join("\n"),
          );

View on GitHub (pinned to a0bd20f762)

Solutions

  1. Add `import { nitro } from "nitro/vite"` and configure `nitro: { preset: "aws-lambda" }` in `vite.config.ts`, then rebuild and redeploy.
  2. Optionally enable streaming with `nitro: { preset: "aws-lambda", awsLambda: { streaming: true } }`.
  3. Verify the fix by checking that `.output/nitro.json` in the build output reports `"preset": "aws-lambda"` before deploying.

Example fix

// before (vite.config.ts)
import { defineConfig } from "vite";
import { tanstackStart } from "@tanstack/react-start/plugin/vite";
export default defineConfig({ plugins: [tanstackStart()] });

// after
import { defineConfig } from "vite";
import { nitro } from "nitro/vite";
import { tanstackStart } from "@tanstack/react-start/plugin/vite";
export default defineConfig({
  plugins: [nitro(), tanstackStart(), ...],
  nitro: { preset: "aws-lambda" },
});
Defensive patterns

Strategy: validation

Validate before calling

import fs from "node:fs";
const nitro = JSON.parse(fs.readFileSync(".output/nitro.json", "utf-8"));
if (nitro.preset !== "aws-lambda")
  throw new Error(`Set nitro preset to "aws-lambda" (got: ${nitro.preset ?? "undefined"})`);

Type guard

null

Try / catch

// VisibleError aborts the Pulumi deploy rather than a call you can wrap;
// guard at build time instead:
import { execSync } from "node:child_process";
execSync("npm run build");
const nitro = JSON.parse(require("fs").readFileSync(".output/nitro.json", "utf-8"));
if (nitro.preset !== "aws-lambda") process.exit(1);

Prevention

When it happens

Trigger: Running `sst deploy` for a TanStack Start app whose `vite.config.ts` exists but whose Nitro config does not set `nitro.preset` (or sets it to something other than `"aws-lambda"`), so the built `.output/nitro.json` has `preset: undefined` or another value.

Common situations: Scaffolding a new TanStack Start app with `tanstackStart()` but no nitro plugin options; upgrading TanStack Start to the Vite/Nitro pipeline and missing the preset migration; setting the preset only in a `.env` or CLI flag that isn't reflected in `nitro.json`.

Related errors


AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30). Data as JSON: /api/errors/b452e9c5dbf1c792. Report an issue: GitHub.