# Server-rendered apps

> Next.js, Astro, SvelteKit, Nuxt and React Router apps that render on the server, on AWS Lambda.

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service).  
Source: https://run.docs.sypnia.com/apps/server-apps/

For agents: SSR apps in Run: static assets on S3, server code as an AWS Lambda behind CloudFront (function URL callable only by CloudFront). Adapters: Next.js 14+ via OpenNext maintained by Run (app/pages router, middleware, image optimization, ISR revalidation), Astro node adapter, SvelteKit adapter-node, Nuxt Nitro aws-lambda, React Router/Remix node. Request flow, per-deploy caching, AWS limits (timeout default 30 s, cold starts, min_instances); use containers for WebSockets/long requests.

A server-rendered app has two halves: files that never change between requests, and code that renders a page per request. Run splits them: the files go to S3 behind CloudFront, the server code becomes an AWS Lambda function that CloudFront calls for dynamic paths.

## Frameworks

| Framework                     | Adapter                                      | Notes                                                                                                                                |
| ----------------------------- | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| Next.js 14 and newer          | OpenNext, maintained by Run                  | App Router and Pages Router, middleware at the edge, image optimization, incremental static regeneration with on-demand revalidation |
| Astro with `output: 'server'` | `@astrojs/node` in a Lambda handler          | server islands and endpoints                                                                                                         |
| SvelteKit                     | `@sveltejs/adapter-node` in a Lambda handler | form actions and endpoints                                                                                                           |
| Nuxt 3                        | Nitro preset `aws-lambda`                    |                                                                                                                                      |
| React Router 7 / Remix        | the Node adapter in a Lambda handler         |                                                                                                                                      |

Run pins the adapter version per deploy, so rebuilding an old commit gives the same result.

## How a request flows

1. CloudFront receives `GET /pedidos/1042`.
2. The edge router finds which deploy the environment points to.
3. A path under the static prefix (`/_next/static/…`, `/_astro/…`) is served from S3.
4. Anything else goes to the deploy's Lambda function, through a function URL only CloudFront can call.
5. The response is cached when it says so (`Cache-Control`), per deploy.

## Limits that come from AWS

- A request can last up to the function's timeout; Run sets 30 seconds by default, and AWS allows at most 15 minutes behind a function URL with response streaming.
- A response body is limited by Lambda's payload size unless the framework streams it.
- The first request after a quiet period starts a new instance (a cold start, usually under a second for Node). `min_instances` keeps instances warm in Sypnia Cloud, metered as idle time.

When these do not fit (WebSockets, very long requests, large memory), deploy the app [as a container](https://run.docs.sypnia.com/apps/containers).
