anomalyco/sst · error · VisibleError

Cannot provide both "edge" and "route". Use the "edge" prop

Error message

Cannot provide both "edge" and "route". Use the "edge" prop on the "Router" component when serving your site through a Router.

What it means

Edge-function configuration (`edge` prop, for Lambda@Edge SSR) is incompatible with serving the site through a Router. If both `edge` and `route` are set, `normalizeRoute` throws to force you to configure edge behavior on the Router instead.

Source

Thrown at platform/src/components/aws/ssr-site.ts:1264

            throw new VisibleError(
              `Invalid AWS region: "${region}". Please specify a valid AWS region.`,
            );
          return region as Region;
        });
      });
    }

    function normalizeRoute() {
      const route = normalizeRouteArgs(args.router, args.route);

      if (route) {
        if (args.domain)
          throw new VisibleError(
            `Cannot provide both "domain" and "route". Use the "domain" prop on the "Router" component when serving your site through a Router.`,
          );

        if (args.edge)
          throw new VisibleError(
            `Cannot provide both "edge" and "route". Use the "edge" prop on the "Router" component when serving your site through a Router.`,
          );

        if (args.protection)
          throw new VisibleError(
            `Cannot set "protection" when routing through a Router. Set "protection" on the Router component instead.`,
          );
      }

      return route;
    }

    function normalizeEdge() {
      return output([args.edge, args.server?.edge]).apply(
        ([edge, serverEdge]) => {
          if (serverEdge)
            throw new VisibleError(
              `The "server.edge" prop is deprecated. Use the "edge" prop on the top level instead.`,

View on GitHub (pinned to a0bd20f762)

Solutions

  1. Remove the `edge` prop from the site component args
  2. If edge is required, drop the `route` prop and configure the site standalone (with domain/protection)
  3. If Router-based serving is required, manage any edge settings on the Router component

Example fix

// before
new sst.aws.NextjsSite("Web", {
  path: "src",
  edge: true,
  route: { router },
});
// after
new sst.aws.NextjsSite("Web", {
  path: "src",
  route: { router },
});
Defensive patterns

Strategy: validation

Validate before calling

if (siteArgs.edge && siteArgs.route) {
  throw new Error('Remove `edge` when using `route`; configure edge on the Router if needed');
}

Try / catch

try {
  new sst.aws.NextjsSite("Web", args);
} catch (e) {
  if (String(e).includes('Cannot provide both "edge" and "route"')) console.error("Drop `edge` or drop `route`");
  throw e;
}

Prevention

When it happens

Trigger: An SSR site component args include both `edge: true` (or an edge config object) and `route: { router }`.

Common situations: Migrating a site that previously used Lambda@Edge to router-based serving; enabling `edge` per old guides while the project also uses a Router for path-based routing.

Related errors


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