# Deploy React Router 7 on forkrail

> Deploy React Router 7 Vite apps with SSR, streaming loaders and actions, SPA mode, and `@vercel/react-router` `vercelPreset()` per-route configuration unchanged.

- Framework: React Router
- Category: Websites & full-stack
- Status: Production ready
- Adapter / Preset: Built-in Vite SSR builder + optional vercelPreset()
- Runtime: Node.js 24 (arm64) or Static S3 (ssr: false)
- Detection: package.json (@react-router/dev)
- Memory: 1,024 MB recommended for SSR
- URL: https://www.forkrail.com/frameworks/react-router

## Capabilities

| Capability | Support | Details |
| --- | --- | --- |
| SSR & streaming | Supported | Vite SSR with streaming loaders, actions, and prerendered routes |
| SPA mode | Supported | ssr: false deploys automatically as a zero-Lambda static site |
| Per-route config | Supported | vercelPreset() supports per-route memory and maxDuration |
| Skew & middleware | Supported | Skew protection and root middleware.ts supported |

## 1. Configure React Router 7

Any React Router 7 Vite project builds and deploys automatically. To use per-route `config` (`memory`, `maxDuration`) or match an existing Vercel setup verbatim, keep `vercelPreset()` in `react-router.config.ts`:

**react-router.config.ts**

```ts
import type { Config } from '@react-router/dev/config'
import { vercelPreset } from '@vercel/react-router/vite'

export default {
  ssr: true,
  presets: [vercelPreset()],
} satisfies Config
```

If `ssr: false` is set, forkrail detects SPA mode and deploys the built client bundle as a zero-Lambda static site served directly from S3.

## 2. Deploy & configure caching

**Deploy React Router 7**

```bash
forkrail project my-rr-app --memory 1024
forkrail deploy --prod
```

To cache loader responses at the regional router, return `Cache-Control: public, s-maxage=60, stale-while-revalidate=300` (or `CDN-Cache-Control`) from your route `headers` export.

> **Node runtime only (no Edge routes):** Routes declaring `export const config = { runtime: 'edge' }` are refused at build time — remove the `runtime` field to run them on Node 24 arm64. pnpm and Yarn workspaces are installed flat (`node-modules`) so server imports resolve reliably.

## Related documentation

- [Image optimization](https://www.forkrail.com/docs/image-optimization.md)
- [Redirects, rewrites & headers](https://www.forkrail.com/docs/routing.md)
- [Deploy from GitHub](https://www.forkrail.com/docs/deploy-from-github.md)
