# forkrail

> The open-source alternative to Vercel, Netlify, Render, Railway, Heroku, and Northflank — running entirely inside your own AWS account.

Git deploys, preview URLs, instant rollbacks (~5 s), an edge firewall, ClickHouse observability, and real-time spend limits for websites and APIs — billed directly by AWS at cost with 0% platform markup and no seat fees.

## Install

- macOS / Linux: `curl -fsSL https://forkrail.com/install | sh`
- Windows (PowerShell): `irm https://forkrail.com/install.ps1 | iex`
- GitHub: https://github.com/forkrail/forkrail

## Key facts

- **License & pricing:** Free and open source (Apache-2.0). AWS bills your account directly with 0% markup. Always-on infrastructure (routers, ClickHouse/Postgres analytics, Global Accelerator) starts around $130/month depending on region count.
- **Architecture:** Global anycast via AWS Global Accelerator → regional Rust routers (TLS, routing rules, edge firewall, ISR/CDN cache, statics, logs) → AWS Lambda arm64 workers over reverse HTTP/2.
- **Concurrent compute:** Up to 10 concurrent requests pack onto one warm Lambda worker so I/O-bound APIs pay for one function instead of ten.
- **Supported regions:** 20 AWS / Vercel region codes.

## Released features

- **Git push deploys** (GitHub App, every branch) — [Docs](https://www.forkrail.com/docs/deploy-from-github.md)
- **Preview URLs** (one per branch and pull request) — [Docs](https://www.forkrail.com/docs/deploy-from-github.md)
- **Instant rollbacks** (immutable deployments (~5 s)) — [Docs](https://www.forkrail.com/docs/deployments-and-rollbacks.md)
- **Custom domains** (automatic Let’s Encrypt TLS certificates) — [Docs](https://www.forkrail.com/docs/domains.md)
- **Environment variables** (per environment and branch, KMS-encrypted) — [Docs](https://www.forkrail.com/docs/environment-variables.md)
- **Cron schedules** (from your existing config) — [Docs](https://www.forkrail.com/docs/cron-schedules.md)
- **Firewall** (rules, rate limits, bot challenge, Attack Mode) — [Docs](https://www.forkrail.com/docs/firewall.md)
- **Deployment protection** (private previews and share links) — [Docs](https://www.forkrail.com/docs/deployment-protection.md)
- **Logs and observability** (every request, searchable in ClickHouse) — [Docs](https://www.forkrail.com/docs/logs-and-observability.md)
- **Image optimization** (plus middleware and skew protection) — [Docs](https://www.forkrail.com/docs/image-optimization.md)
- **Spend limits** (team and project budgets with auto-pause) — [Docs](https://www.forkrail.com/docs/spend-budgets.md)
- **Team access** (GitHub sign-in, no seat fees) — [Docs](https://www.forkrail.com/docs/team-and-sign-in.md)
- **Redirects, rewrites, headers** (your routing rules, as written) — [Docs](https://www.forkrail.com/docs/routing.md)
- **Functions in api/** (Node and Python side by side) — [Docs](https://www.forkrail.com/docs/functions.md)
- **Notifications and webhooks** (deploys, budgets and incidents) — [Docs](https://www.forkrail.com/docs/notifications.md)
- **Your choice of region** (run where your users are) — [Docs](https://www.forkrail.com/docs/function-regions.md)

## Supported frameworks & runtimes

- **SvelteKit**: @sveltejs/adapter-vercel · ssr + isr + images — [Guide](https://www.forkrail.com/frameworks/sveltekit.md)
- **Astro**: @astrojs/vercel · islands + edge middleware — [Guide](https://www.forkrail.com/frameworks/astro.md)
- **Nuxt**: nitro vercel preset · routeRules + crons — [Guide](https://www.forkrail.com/frameworks/nuxt.md)
- **TanStack Start**: streaming ssr · powers forkrail’s own dashboard — [Guide](https://www.forkrail.com/frameworks/tanstack-start.md)
- **React Router**: react router 7 · vercelPreset() verbatim — [Guide](https://www.forkrail.com/frameworks/react-router.md)
- **Remix**: remix 2 · streaming loaders & actions — [Guide](https://www.forkrail.com/frameworks/remix.md)
- **Vite**: zero-lambda content-hashed s3 delivery — [Guide](https://www.forkrail.com/frameworks/vite.md)
- **Next.js** (Beta): beta · shared router cache & tag revalidation — [Guide](https://www.forkrail.com/frameworks/nextjs.md)
- **FastAPI**: python 3.13 arm64 · 10× concurrent asgi — [Guide](https://www.forkrail.com/frameworks/fastapi.md)
- **Django**: python 3.13 · same-vpc rds + kms secrets — [Guide](https://www.forkrail.com/frameworks/django.md)
- **Flask**: python 3.13 wsgi · zero wrapper needed — [Guide](https://www.forkrail.com/frameworks/flask.md)
- **Express**: node 24 arm64 · loopback http/1.1 — [Guide](https://www.forkrail.com/frameworks/express.md)
- **Hono**: web fetch standard · native typescript — [Guide](https://www.forkrail.com/frameworks/hono.md)
- **Go**: compiled arm64 binary · low-memory cold starts — [Guide](https://www.forkrail.com/frameworks/go.md)
- **Rust**: cargo [[bin]] · native aarch64 release — [Guide](https://www.forkrail.com/frameworks/rust.md)

---

# Introduction

> forkrail is a free, open-source hosting platform for websites and APIs. You install it in your own AWS account, and it works the way Vercel works: push code, get a preview URL, ship to production, roll back in seconds.

- Category: Get started
- URL: https://www.forkrail.com/docs

## What forkrail is

forkrail is a complete hosting platform that runs inside an AWS account you own. One command sets it up. After that your team gets the workflow it already knows from Vercel: connect a GitHub repository, push a branch to get a preview URL, merge to deploy production, and roll back any release instantly.

It reads the configuration you already have. `vercel.json` (redirects, rewrites, headers, crons, functions, images) works as it is, and frameworks build through their own Vercel adapters, so most projects move without a code change.

- **Open source and free.** forkrail is Apache-2.0 licensed. There is no forkrail bill, no seat price and no usage tier. The source is on [GitHub](https://github.com/forkrail/forkrail).
- **Your account, your bill.** Functions, files, logs and secrets stay in your AWS account. AWS bills you directly at its own prices, and your AWS credits and discounts apply. See [Pricing and costs](https://www.forkrail.com/docs/pricing).
- **Production-ready building blocks.** Requests go through forkrail’s own router, functions run on AWS Lambda, static files are served from S3, and logs land in ClickHouse, all in your account.

> **Public beta:** forkrail is in public beta. Install it with one command or the Mac app (see the [Quickstart](https://www.forkrail.com/docs/quickstart)). Releases are published on GitHub at `github.com/forkrail/forkrail`.

## What you get

| Feature | What it does |
| --- | --- |
| [Git deploys](https://www.forkrail.com/docs/deploy-from-github) | Every push builds. Branches get preview URLs, the production branch goes live, pull requests get a status comment. |
| [CLI deploys](https://www.forkrail.com/docs/deploy) | `forkrail deploy` uploads a folder and builds it in your account. `--prod` ships it. |
| [Instant rollback](https://www.forkrail.com/docs/deployments-and-rollbacks) | Every deployment keeps its own URL and Lambda version. Rolling back moves production in about five seconds, with no rebuild. |
| [Frameworks](https://www.forkrail.com/docs/frameworks) | SvelteKit, Astro, Nuxt, TanStack Start, React Router, Remix, static sites, and Next.js (beta). |
| [APIs](https://www.forkrail.com/docs/languages) | Python (FastAPI, Flask, Django), Node.js (Express, Hono, Fastify, NestJS), Go and Rust. |
| [Concurrent compute](https://www.forkrail.com/docs/concurrent-compute) | Many requests share one warm worker, so I/O-bound APIs pay for one environment instead of ten. |
| [Domains](https://www.forkrail.com/docs/domains) | Custom domains, apex and wildcard domains, automatic Let’s Encrypt certificates, redirects and branch domains. |
| [Firewall](https://www.forkrail.com/docs/firewall) | Custom rules, IP blocks, rate limits, bot challenges and Attack Mode, in front of every deployment. |
| [Logs](https://www.forkrail.com/docs/logs-and-observability) | Every request and every line your app prints, searchable, with latency, cold starts and outgoing calls. |
| [Spend limits](https://www.forkrail.com/docs/spend-budgets) | Monthly budgets that pause a project within about a second of being reached. |

## How the pieces fit

A visitor’s request reaches a forkrail **router**, a small EC2 server in your account. The router checks the firewall, serves static files and cached pages itself, and sends everything else to your app’s **function** on AWS Lambda. Builds run in a **builder** function in the same account. The **dashboard** is itself a forkrail project, served at `dashboard.<your domain>`. [How forkrail works](https://www.forkrail.com/docs/how-forkrail-works) walks through each part.

## Where to go next

- [Quickstart](https://www.forkrail.com/docs/quickstart): Install forkrail and deploy your first app.
- [Moving from Vercel](https://www.forkrail.com/docs/moving-from-vercel): Move a project, check a preview side by side, switch DNS.
- [Pricing and costs](https://www.forkrail.com/docs/pricing): What the install costs a day, and what traffic costs on AWS.
- [Differences from Vercel](https://www.forkrail.com/docs/vercel-differences): What works the same, what works differently, and what is not built yet.
- [CLI reference](https://www.forkrail.com/docs/cli): Every `forkrail` command and its options.
- [Limits](https://www.forkrail.com/docs/limits): Sizes, timeouts and counts, side by side with Vercel’s.

---

# Quickstart

> Install the CLI, set forkrail up in your AWS account, and deploy a preview and then production. It takes about 20 minutes, most of it waiting.

- Category: Get started
- URL: https://www.forkrail.com/docs/quickstart

## Before you start

- **An AWS account** where you can sign in as an administrator or the root user (the root user needs MFA turned on).
- **A domain whose DNS is on Cloudflare.** The free plan is enough. Your apps get names under it, like `my-app.example.com`.
- **A GitHub account.** You and your team sign in to the dashboard with it.

You don’t need Docker, Rust or the AWS CLI. [Install forkrail](https://www.forkrail.com/docs/install) covers every requirement and option in detail.

## Install and set up

1. **Install the CLI**

   On macOS or Linux, run the install script. On Windows, use PowerShell: `irm https://forkrail.com/install.ps1 | iex`. On a Mac you can also download the app from `forkrail.com/download/mac`, which runs the same installer in a window.

```bash
curl -fsSL https://forkrail.com/install | sh
```

2. **Run the installer**

   A page opens in your browser. Sign in to AWS, answer a few questions (domain, region, alert email, Cloudflare token) and click once on GitHub to create your install’s GitHub App. The installer checks the account before it changes anything, then sets everything up on its own in about 15 minutes.

```bash
forkrail install
```

3. **Open the dashboard**

   When it finishes, open `https://dashboard.<your domain>` and choose **Continue with GitHub**. Whoever created the GitHub App is the install’s first owner.

4. **Sign in the CLI**

   This links your terminal to the install. A page opens where you approve it with your GitHub sign-in. No AWS keys are needed for day-to-day work.

```bash
forkrail login https://dashboard.example.com
```

## Deploy your first app

1. **Deploy a preview**

   Run `forkrail` in your project’s folder (it’s short for `forkrail deploy`). forkrail finds the framework, uploads the source, builds it in your account and prints a preview URL. The project is named after the folder unless you pass `--project`.

```bash
cd ~/code/my-app
forkrail
# Preview: https://my-app-9f4a2d1c.example.com
```

2. **Ship it to production**

   Add `--prod`. The production URL is `https://<project>.<your domain>`, and you can add your own domain to it later.

```bash
forkrail --prod
# Production: https://my-app.example.com
```

3. **Roll back if you need to**

   Production moves back to the previous production deployment in about five seconds, without a rebuild.

```bash
forkrail rollback my-app
```

> **Prefer deploying from GitHub?:** In the dashboard choose **New project**, **Import** a repository, and click **Deploy**. From then on every push deploys: branches to previews and the production branch to production. See [Deploy from GitHub](https://www.forkrail.com/docs/deploy-from-github).

## Next steps

- [Add a custom domain](https://www.forkrail.com/docs/domains): Serve production on your own domain with an automatic certificate.
- [Set environment variables](https://www.forkrail.com/docs/environment-variables): Encrypted secrets for production, previews and local development.
- [Invite your team](https://www.forkrail.com/docs/team-and-sign-in): Add teammates by GitHub username and pick their roles.
- [Set a spend limit](https://www.forkrail.com/docs/spend-budgets): Pick a monthly budget so a runaway loop can’t run up a bill.

---

# Install forkrail

> One command, `forkrail install`, sets forkrail up in an AWS account. It checks the account first, changes nothing until the checks pass, and picks up where it stopped if you run it again.

- Category: Get started
- URL: https://www.forkrail.com/docs/install

## Get the CLI

**macOS and Linux**

```bash
curl -fsSL https://forkrail.com/install | sh
```

**Windows (PowerShell)**

```bash
irm https://forkrail.com/install.ps1 | iex
```

The script downloads the newest release from GitHub, checks it against its SHA-256, and puts `forkrail` in `~/.local/bin` (set `FORKRAIL_BIN` to choose another folder). It runs on macOS (Apple silicon and Intel), Linux (x86_64 and arm64) and Windows (x64 and Arm64). The macOS builds are signed and notarized by Apple.

**On a Mac without Terminal:** download Forkrail.dmg from `forkrail.com/download/mac`, drag Forkrail to Applications and open it. The app is the same installer with its page in a window of its own. AWS and GitHub sign-in still open in your browser, where passkeys work.

## What you need

| Requirement | Details |
| --- | --- |
| An AWS account | Sign in as an administrator or the root user: the install creates roles, keys and servers. The root user needs an MFA device first (IAM → Security credentials → Assign MFA device; a passkey takes a minute). The installer signs you in itself, so the AWS CLI isn’t needed. A computer already signed in (`aws login`, `aws sso login`, an access key, CloudShell) is used as it is. |
| A domain on Cloudflare DNS | The free plan is enough. Apps get `<project>.<domain>` and the dashboard `dashboard.<domain>`. The installer adds one record, `*.<domain>`, and never touches records it didn’t make. |
| A Cloudflare API token | With DNS edit and zone read on that domain. The setup page has a button that opens Cloudflare with the token filled in: click **Continue to summary**, then **Create Token**, and paste it. |
| A GitHub account | The installer creates a GitHub App for your install. Your team signs in to the dashboard with it, and it reads repositories you choose to deploy. |
| An email address (optional) | For alerts: the monthly budget and certificate problems. |

### If your domain’s DNS is somewhere else

The installer asks where your DNS is first. If it’s at GoDaddy, Namecheap, Route 53 or anywhere else, it shows how to move it and stops before changing anything. The domain stays registered where it is; only its DNS moves.

1. **Add the domain to Cloudflare**

   Use the free plan.

2. **Change the nameservers**

   Where you bought the domain, replace its nameservers with the two Cloudflare shows.

3. **Run the installer again**

   When Cloudflare says the domain is active (usually within an hour), run `forkrail install` again.

## Run the installer

```bash
forkrail install
```

Everything you do happens in the first few minutes:

1. **Sign in to AWS**

   Click **Sign in to AWS** on the page. AWS’s sign-in page opens in your browser. Sign in to the account forkrail goes in.

2. **Answer the questions**

   Where your DNS is, the domain, the AWS region (US East, N. Virginia unless you pick another), an alert email and the Cloudflare token.

3. **Wait for the checks**

   The installer checks the account’s limits and the token. Nothing is created until they pass.

4. **Create the GitHub App**

   Click **Create the GitHub App**. GitHub opens with the app filled in: click **Create GitHub App**. If GitHub asks you to confirm your password or passkey and then shows an empty form, click the page’s button again.

Then it sets everything up on its own and shows each step as it runs. The release (about 1 GB: the router, the functions, the builder image and the dashboard) is copied from GitHub straight into your account by a short-lived function there, so nothing that size goes through your connection.

When it finishes, open `https://dashboard.<your domain>` and sign in with GitHub.

### On a server, or from a script

Over SSH the same questions come in the terminal, and AWS sign-in prints an address to open on your phone or laptop. `--terminal` keeps everything in the terminal anywhere. For a run with no one to answer:

```bash
FORKRAIL_CLOUDFLARE_TOKEN=... forkrail install --yes \
  --domain example.com --region us-east-1 --email you@example.com

# Only run the checks, change nothing
forkrail install --check
```

## What it creates

Everything is made with CloudFormation stacks named `forkrail-*` and tagged `project=forkrail`. Steps that don’t depend on each other run side by side.

| Part | What it is |
| --- | --- |
| Bucket | `forkrail-artifacts-<account>`: packages, static files, build logs and state. |
| Encryption keys | AWS KMS keys for environment variables and the install’s own secrets. |
| Roles | IAM roles for the router, the log server, the dashboard and your apps, each allowed only what it needs. |
| Router | A t4g.small EC2 server with a fixed address. It takes every request, gets certificates from Let’s Encrypt, and runs apps on Lambda. |
| Log server | ClickHouse on a t4g.medium with a 50 GB disk, for request logs, app output and Web Analytics. |
| Services | Lambda functions for builds, deploys, notifications, image optimization and page screenshots, plus DynamoDB tables, queues and schedules. |
| DNS record | `*.<domain>`, pointed at the router. |
| Dashboard | Deployed as a forkrail project at `dashboard.<domain>`. |
| Spend protection | An AWS Budget on everything forkrail runs (see below). |
| GitHub App | Your install’s own app, with its keys stored encrypted in your account. |

## What it costs

forkrail itself is free. The servers it runs on are billed by AWS. A fresh install in one region costs about **$1.80 a day** before any traffic (us-east-1 prices):

| Item | About |
| --- | --- |
| Router (t4g.small with a fixed address) | $0.45 a day |
| Log server (t4g.medium, 50 GB disk) | $0.90 a day |
| Public addresses, disks, keys, the audit trail | $0.45 a day |
| Your apps: Lambda, S3, data transfer | What they use. Idle apps cost nothing. |

The install also creates an AWS Budget of $150 a month on everything it runs (`FORKRAIL_INSTALL_BUDGET=300` changes it). At 100% it stops forkrail’s functions, so a runaway bill can’t happen, and AWS emails you at 80% and 100%. Inside forkrail, the team’s [spend limit](https://www.forkrail.com/docs/spend-budgets) starts at $20 a month. [Pricing and costs](https://www.forkrail.com/docs/pricing) has the full breakdown.

## If something fails

Each AWS call is tried twice. If it still fails, the installer stops and prints what it was doing, what went wrong in plain words, how to fix it, and AWS’s own message. Run `forkrail install` again to continue from that step; the steps before it are kept.

| Message | What to do |
| --- | --- |
| “You must have a multi-factor authentication (MFA) device configured” | You signed in as the root user without MFA. Add an MFA device, sign out of the AWS console, and run the installer again. |
| “AWS is still verifying this new account” | New accounts can’t start servers for a while. Wait for AWS’s email, then run it again. |
| Function memory limited to 512 MB | Some new accounts start with a lower Lambda memory limit. Nothing stops: every function is sized to fit and the dashboard shows the limit under Infrastructure. A free support case asking for 10,240 MB raises it sooner. |
| vCPU limit | The two servers need 4 vCPUs. The check links to Service Quotas to ask for 8. |
| Cloudflare token | The token can’t edit the zone, or the zone isn’t active yet. The check says which. |

The installer never asks AWS for more Lambda concurrency. A new account’s starting limit is enough to begin with, and AWS raises it as the account is used.

## Change your answers

Run the installer again. The page shows your previous answers and you can change any of them. A new email or Cloudflare token is used from then on. A finished install keeps its domain and region.

## Uninstall

```bash
forkrail uninstall
```

It asks you to type the domain, then deletes everything the installer made: servers, disks, addresses, apps and their data, the dashboard, buckets, tables, secrets, logs, the budget and the DNS records, in every region it used. AWS deletes the encryption keys 7 days later. The GitHub App stays on GitHub, where only you can delete it; the command prints its page.

---

# How forkrail works

> A router in your AWS account takes every request, answers what it can by itself, and runs your code on AWS Lambda workers that keep a connection open to it.

- Category: Get started
- URL: https://www.forkrail.com/docs/how-forkrail-works

## The path of a request

**A request, from visitor to function**

```text
visitor ──▶ *.example.com (DNS) ──▶ forkrail router (EC2, your account)
                                          │
        ┌──────────────┬──────────────────┼──────────────────┬───────────────┐
        ▼              ▼                  ▼                  ▼               ▼
    firewall      redirects and      static files      cached pages     your function
    and rules     routing rules      (S3, memory)      (ISR, s-maxage)  (AWS Lambda)
```

1. **DNS sends the visitor to the router**

   `*.<your domain>` points at the router’s fixed address. Custom domains point there too, with a CNAME or A record.

2. **The router decides**

   It terminates TLS, finds the deployment by hostname, runs the firewall and deployment protection, then the project’s redirects and routing rules.

3. **It answers what it can**

   Static files come from S3 (the busiest from memory) and cached pages from its own cache. Neither wakes a function.

4. **Everything else runs your code**

   The request goes to a worker of the deployment’s Lambda function. The response streams back through the router to the visitor.

## Workers that dial back

A Lambda worker opens a connection back to the router when it starts and keeps it open while it runs. With [concurrent compute](https://www.forkrail.com/docs/concurrent-compute) on (the default), the router sends one worker up to 10 requests at once over that connection, so an API that spends most of its time waiting on a database pays for one environment instead of ten.

- **Idle costs nothing.** Every deployment is a published Lambda version. Previews and old releases cost nothing until someone opens them.
- **Warm before it’s live.** Before production moves to a new deployment, forkrail starts a few of its environments so the first visitors don’t wait for a cold start.
- **Keep warm, if you want it.** A project can ask the routers to keep environments ready around the clock. See [Function settings](https://www.forkrail.com/docs/functions#keep-warm).

## The parts in your account

| Part | Runs on | What it does |
| --- | --- | --- |
| Router | EC2 (Graviton) | TLS, routing, firewall, static files, response cache, rate limits, metering for spend limits. |
| Workers | AWS Lambda (arm64) | Your functions. One Lambda function per project, one version per deployment. |
| Builder | AWS Lambda (container image) | Builds every deploy from source, on the same Linux your functions run on. |
| Control | AWS Lambda | Publishes deployments, promotes, rolls back, and holds the rights to decrypt env vars. |
| Storage | S3 and DynamoDB | Packages, static files, the routing table, project settings and deployment records. |
| Logs | ClickHouse on EC2 | Every request, app log line, outgoing call and Web Analytics event. |
| Dashboard | A forkrail project | The web app your team signs in to, deployed like any other project. |

## Regions and failover

An install has one router, in the region you pick when you install. Each project then picks the regions its functions run in, from 20 AWS regions, with no router needed there: the router invokes the function in that region, so a function can sit next to its database wherever that is. See [Function regions](https://www.forkrail.com/docs/function-regions).

The router can also run in several regions at once, behind two anycast addresses (AWS Global Accelerator) that send each visitor to the nearest healthy router and move them to another region in under a minute if one stops answering. Setting up a second router region is a manual step today; the installer sets up one. Router updates start the new router beside the old one, so restarts have no gap.

## Who can read what

- Environment variable values are encrypted with a KMS key that only the control function and your administrators can use. The routers, the dashboard and your apps can’t read other projects’ values.
- The builder can’t reach the install’s state, secrets or other projects. It reads its source and writes its output through URLs signed for that one build.
- Project settings and team data live in DynamoDB tables whose resource policies refuse everyone but the services that need them, with point-in-time recovery for 35 days.
- Every change is recorded with who made it.

---

# Pricing and costs

> forkrail is free and open source. You pay AWS for the servers and the traffic, at AWS’s own prices, on your own AWS bill.

- Category: Get started
- URL: https://www.forkrail.com/docs/pricing

## forkrail is free

There is no forkrail plan, seat price, bandwidth tier or invoice. forkrail is Apache-2.0 software you install in your own AWS account. AWS bills you for what runs there, and AWS credits, Savings Plans and private pricing apply as they do for anything else in the account.

## Fixed costs

These run whether or not anyone visits your apps. A fresh install in one region costs about **$1.80 a day, around $55 a month** (us-east-1 prices):

| Item | Per day | Per month |
| --- | --- | --- |
| Router: t4g.small with a fixed address | ~$0.45 | ~$14 |
| Log server: t4g.medium, 50 GB disk | ~$0.90 | ~$27 |
| Addresses, disks, KMS keys, audit trail | ~$0.45 | ~$14 |

- **A second router region** (a manual setup today) adds a router like the first, and AWS Global Accelerator to put both behind one anycast address ($0.025 an hour, about $18 a month, plus a per-GB premium).
- **A function region without a router** adds only an encryption key there, about $1 a month.

## Usage costs

Everything else is billed by use at AWS list prices. These are the rates forkrail’s own meters use for [spend limits](https://www.forkrail.com/docs/spend-budgets):

| What | AWS price | Notes |
| --- | --- | --- |
| Function time (Lambda, arm64) | $0.0000133334 per GB-second | Billed for the memory you set, from start to finish of each invocation. With concurrent compute, requests that overlap share one invocation. |
| Function invocations | $0.20 per million | One per worker start, not per request, when requests share a worker. |
| Data to visitors | $0.09 per GB | EC2 data transfer out, first 10 TB a month. Global Accelerator adds $0.015/GB in North America and Europe when you run more than one router region. |
| Router to workers | $0.01 per GB each way | $0.02 per GB between regions. |
| Static files | S3 storage and requests | About $0.023 per GB-month, $0.0004 per 1,000 reads. Files in a router’s memory cost nothing to serve. |
| Builds | Lambda time | The builder’s memory (4 GB, or 8 GB for large builds) for as long as each build runs. |
| Image Optimization | Lambda time and S3 | About $0.011 per 1,000 WebP resizes. Each image is resized once and kept. |

> **Free tiers:** AWS’s free allowances (for example a million Lambda requests and 100 GB of data transfer out a month) come off your bill as usual. forkrail’s spend meters leave them out on purpose, so a budget errs high, never low.

## Worked examples

Rough monthly AWS costs on top of the install’s fixed cost, at list prices with no free tier:

| App | Traffic | About |
| --- | --- | --- |
| Static site | 500,000 page views, 40 GB out | ~$3.60 to $4.60: transfer $3.60, plus S3 reads for files not already in the router’s memory. No function runs. |
| JSON API at 640 MB | 5 million requests at 150 ms, 10 GB out | Up to ~$8.40: Lambda time $6.25, invocations $1.00, transfer ~$1.10. Less when requests overlap on one worker. |
| SSR site at 1,024 MB | 2 million renders at 80 ms, 60 GB out | Up to ~$8.50: Lambda time $2.13, invocations $0.40, transfer ~$6.00. |

Lambda time is memory × duration: 5 million requests × 0.15 s × 0.625 GB = 468,750 GB-seconds, about $6.25, plus $1 for invocations if every request had its own. Run `forkrail usage` to see what each project actually used and cost, next to an estimate of the same traffic on Vercel.

## Keeping costs down

- **Right-size memory.** An API that mostly waits on other servers runs as fast at 256 MB as at 640 MB. Memory buys CPU (a full core at 1,769 MB), so CPU-heavy work like SSR benefits from more. See [Function settings](https://www.forkrail.com/docs/functions).
- **Leave concurrent compute on** for I/O-bound APIs, so overlapping requests share one worker.
- **Cache.** Pages and API responses with `s-maxage` are served by the router without running your function. See [Caching and ISR](https://www.forkrail.com/docs/caching).
- **Let the router compress.** It sends pages, JSON and other text in Brotli or gzip to clients that ask, so large answers shrink to about a tenth. Leave out compression middleware unless you need it; a route that sets `content-encoding: identity` turns it off.
- **Set a spend limit.** A budget pauses a project within about a second of being reached. See [Spend limits](https://www.forkrail.com/docs/spend-budgets).

---

# Moving from Vercel

> Most projects move without a code change. Copy the environment variables, compare a preview side by side, then switch the domain with no downtime.

- Category: Get started
- URL: https://www.forkrail.com/docs/moving-from-vercel

## What carries over unchanged

- `vercel.json`, `vercel.toml` or `vercel.ts`: redirects, rewrites, headers, `cleanUrls`, `trailingSlash`, `crons`, `functions`, `images`, `regions`, `fluid`, `git.deploymentEnabled` and `ignoreCommand`. See the [vercel.json reference](https://www.forkrail.com/docs/vercel-json).
- Framework adapters: `@sveltejs/adapter-vercel`, `@astrojs/vercel`, Nitro’s `vercel` preset, `@vercel/react-router` and `@vercel/remix`.
- System variables your code reads: `VERCEL=1`, `VERCEL_ENV`, `VERCEL_URL`, `VERCEL_BRANCH_URL`, `VERCEL_PROJECT_PRODUCTION_URL`, `VERCEL_REGION`, `VERCEL_DEPLOYMENT_ID` and the `VERCEL_GIT_*` variables.
- Request headers: `x-vercel-forwarded-for`, `x-vercel-id` and the `x-vercel-ip-*` location headers.
- Packages: `@vercel/functions` (`waitUntil`, `geolocation`, `ipAddress`), `@vercel/analytics` (reports to forkrail’s [Web Analytics](https://www.forkrail.com/docs/web-analytics)), `@vercel/firewall` rate limit checks, `@vercel/og`, `@vercel/otel`, and services you reach with your own key (Neon, Upstash, Edge Config).

## Move a project

1. **Create the project**

   Import the repository in the dashboard (**New project → Import**) or deploy it once from your terminal. Use the same root directory as on Vercel for a monorepo.

```bash
cd ~/code/storefront
forkrail
```

2. **Copy the environment variables**

   Paste your `.env` into the dashboard’s Environment variables page, or add them with `forkrail env add`. Leave out `VERCEL_OIDC_TOKEN`: it’s a 12-hour Vercel token.

```bash
printf '%s' "$DATABASE_URL" | forkrail env add storefront DATABASE_URL --target production
```

3. **Check a preview side by side**

   Deploy a preview and request the same pages on both: status codes, headers (`x-vercel-cache`), streamed pages, images, forms, and an API call or two. The build log warns about any Vercel-only service your code uses (below).

4. **Deploy production**

   Production is live at `https://<project>.<your domain>` while Vercel keeps serving your real domain.

```bash
forkrail --prod
```

5. **Move the domain without a gap**

   Add the domain in forkrail and let it get a certificate before DNS moves (the `_acme-challenge` record, or automatically on Cloudflare). Lower the record’s TTL, then point it at forkrail. Keep the Vercel deployment until traffic has moved. See [Domains](https://www.forkrail.com/docs/domains#move-without-downtime).

```bash
forkrail domains add shop.example.com storefront
forkrail domains ls storefront   # wait for "issued"
```

## Services that need a key of their own

Some Vercel services sign in with an OIDC token that only Vercel can issue to its own functions. On forkrail they build and deploy, then fail at their first call. The build looks for them and prints a warning with the fix:

| Package | Fix |
| --- | --- |
| `ai` 5+ / `@ai-sdk/gateway` (AI Gateway) | Set `AI_GATEWAY_API_KEY`, or call a provider directly, such as `@ai-sdk/amazon-bedrock` with a project IAM role. |
| `@vercel/blob` | Set `BLOB_READ_WRITE_TOKEN`, or move the files to S3. |
| `workflow` (Workflow SDK) | Set `WORKFLOW_TARGET_WORLD=@workflow/world-postgres` with a Postgres URL. |
| `@vercel/flags-core`, `@flags-sdk/vercel` | Set the `FLAGS` SDK key. |
| `@vercel/sandbox` | Pass a `VERCEL_TOKEN`, team id and project id to `Sandbox.create`. |
| `@vercel/queue` | Use a queue in your own account, such as SQS, with a project role. |
| `@vercel/kms`, `@vercel/oidc-aws-credentials-provider` | Give the project an IAM role: `forkrail project NAME --role ROLE`. The AWS SDK picks it up with no keys. |
| `@vercel/passport` | Sign-in in the app, or [deployment protection](https://www.forkrail.com/docs/deployment-protection) for a team-only site. |
| `upgradeWebSocket()` | WebSockets aren’t supported yet. Use a WebSocket service of its own. |

## Also worth checking

- `*.vercel.app` URLs in code or settings: OAuth redirect URIs, CORS lists, `NEXTAUTH_URL`.
- Integration variables Vercel added for you (`KV_REST_API_*`, `POSTGRES_URL*`, `EDGE_CONFIG`, `UPSTASH_*`, `DATABASE_URL`): bring them along.
- Compression works as on Vercel: the router compresses text answers (Brotli or gzip) for clients that ask, and leaves alone any your app already compressed or marked `content-encoding: identity`.
- Next.js is in beta on forkrail. Read [Frameworks](https://www.forkrail.com/docs/frameworks#nextjs) before moving a Next.js site.

---

# Differences from Vercel

> forkrail follows Vercel’s behavior wherever it can, down to headers and error codes. This page lists where it differs on purpose, and what isn’t built yet.

- Category: Get started
- URL: https://www.forkrail.com/docs/vercel-differences

## What works the same

- Git previews, branch URLs, production branch deploys, pull request comments, deploy hooks, `ignoreCommand` and `git.deploymentEnabled`.
- Promote, Instant Rollback, Redeploy, staged production deployments and deployment retention.
- `vercel.json` routing (redirects, rewrites, headers, `cleanUrls`, `trailingSlash`, `routes`), bulk redirects, project routing rules, crons, Image Optimization, ISR, skew protection and Routing Middleware.
- Environment variables per environment and per branch, with Vercel’s system variable names and the 64 KB limit.
- The firewall: custom rules, IP blocks, rate limits, Attack Mode, and a Vercel firewall export imports as it is.
- Response headers (`x-vercel-cache`, `x-vercel-id`), error codes (`FUNCTION_INVOCATION_TIMEOUT`, `FUNCTION_PAYLOAD_TOO_LARGE`) and request limits.

## What works differently

| Area | Vercel | forkrail |
| --- | --- | --- |
| Where it runs | Vercel’s cloud | Your AWS account |
| Billing | Vercel plans, seats and usage | Free software; AWS bills you at its prices |
| Team sign-in | Vercel accounts, SSO on Enterprise | GitHub, through your install’s own GitHub App; unlimited members |
| Concurrency | Fluid compute | [Concurrent compute](https://www.forkrail.com/docs/concurrent-compute): up to 10 requests share one worker by default (2 to 50, set per project). More workers start as traffic grows, with no cap of forkrail’s own. |
| A deployment’s functions | Each function runs on its own | All of a deployment’s functions share one Lambda function at the largest memory any of them asks for |
| Edge functions and middleware | Edge runtime | Run on Node.js in the deployment’s own function (Vercel now recommends Node for both) |
| Build time limit | 45 minutes | 15 minutes in the builder (Lambda’s limit); longer builds can run on your machine with `--local` |
| Compression | The CDN compresses text | The router compresses text (Brotli, else gzip); answers your app compressed go as they are |
| POST caching | Some POST answers can be cached | POST responses are never cached |
| Function regions | `regions` in vercel.json | The same setting, plus routers you can add in any AWS region |
| Edge network | Points of presence worldwide | A router in your install’s region; functions in any of 20 AWS regions |
| Spend control | Spend Management | [Spend limits](https://www.forkrail.com/docs/spend-budgets) that pause a project within about a second, plus an AWS Budget backstop |
| Logs | Kept per plan | Kept in your own ClickHouse for as long as you keep them |

## Not built yet

- **WebSockets.** Functions don’t accept WebSocket connections.
- **Edge regions.** The router runs in your install’s region, not at points of presence around the world. More router regions are coming to the installer.
- **Sign-in other than GitHub** for the dashboard.
- **Next.js** is in beta: it builds, deploys and shares one cache across workers, but isn’t recommended for critical production yet.
- **Cache tag invalidation** of optimized images by source image.
- **Functions over 250 MB** unzipped (Lambda’s limit; container images aren’t supported yet).
- **Vercel services that use OIDC** (AI Gateway without a key, Blob without a token, Queues, Sandbox without a token). See [Moving from Vercel](https://www.forkrail.com/docs/moving-from-vercel#vercel-only-services).

For the full picture of features and plans, see [forkrail vs Vercel](https://www.forkrail.com/compare/vercel). For hard numbers, see [Limits](https://www.forkrail.com/docs/limits).

---

# Deploy with the CLI

> `forkrail` uploads a folder, builds it in your own AWS account, and prints a URL. Add `--prod` to ship it to production.

- Category: Deploy
- URL: https://www.forkrail.com/docs/deploy

## Deploy a folder

**Preview, production, and options**

```bash
# A preview of the current folder
forkrail

# Production
forkrail --prod

# Another folder, under a name you choose
forkrail ~/code/my-api --project my-api

# This deployment only: 1,024 MB of memory
forkrail --memory 1024
```

As with `vercel`, no command means deploy: `forkrail` is short for `forkrail deploy`, and both take the same options. A command’s name is the command, so a folder named like one is written as a path: `forkrail ./build`. Your home folder and the disk’s root are refused, since every file in them would be uploaded.

The first deploy of a name creates the project. Each deploy prints the deployment’s own URL, `https://<project>-<id>.<your domain>`, and a production deploy also moves `https://<project>.<your domain>` and the project’s custom domains to it.

The deployment shows up in the dashboard as soon as the deploy starts, with its build log live. It ends **Ready**, **Error** (with the step that failed and why) or **Canceled**.

## Where builds run

Every deploy builds in your install’s **builder**, a Lambda function in your AWS account, the way Vercel builds on its machines rather than yours. The terminal uploads the source and shows the log as it’s written. Closing the terminal doesn’t stop the build.

- **The build runs where the app runs:** Amazon Linux 2023 on arm64, with the Python and Node versions your project asks for, plus Go and Rust. Native packages install for the right platform.
- **What’s uploaded** is what a git checkout would have: files your `.gitignore` and `.vercelignore` leave out stay behind, and so do dependencies, build output, caches and `.env.local` files. The upload is encrypted under your install’s key. At most 100,000 files and 1 GB.
- **Memory:** builds get 4,096 MB. A build that runs out of memory is retried once on a larger builder with 8,192 MB, and the project’s later builds start there.
- **Time:** a build has 15 minutes, Lambda’s limit. Longer builds can run on your own machine with `--local`.
- **Nothing else is reachable:** the builder reads its source and writes its output through URLs signed for that one build, so your build scripts can’t reach the install’s state, secrets or other projects.

### The build cache

After a successful build, the builder keeps the project’s dependencies (`node_modules`, installed Python requirements, Go and Cargo caches, and Next.js’s `.next/cache`) and restores them on the next build. The install command still runs every time, as on Vercel, and has little left to do. Production builds use production’s cache; previews use the previews’ (or production’s until there is one). A cache is rebuilt from scratch after 30 days.

```bash
# Build without the cache (a new one is written), like vercel --force
forkrail deploy --no-cache
```

## Build logs and canceling

- The log shows each step: preparing, installing dependencies, building, packaging and publishing, with every line your build prints.
- Any environment variable value of 8 characters or more is replaced by `[NAME hidden]` in the dashboard’s copy of the log.
- Logs are kept up to 4 MB each, for as long as the deployment is kept.
- Cancel a build from the deployment’s page or with `forkrail cancel <id>`. It stops within a few seconds and nothing is published. Ctrl-C in the terminal only stops showing the log.

```bash
forkrail inspect <id> --logs   # print a finished build’s log
forkrail cancel <id>           # stop a build
```

## Local, prebuilt and split builds

| Command | What it does |
| --- | --- |
| `forkrail deploy --local` | Builds on your machine instead of the builder. Needs the install’s AWS credentials. |
| `forkrail deploy --prebuilt` | Deploys a `.vercel/output` (or Nitro `.output`, or Next.js standalone) you already built, as it is. |
| `forkrail build DIR --out OUT` | Builds only, into a folder, like `vercel build`. With `--request FILE` it needs no AWS access at all. |
| `forkrail publish OUT` | Publishes a folder `forkrail build` made, like `vercel deploy --prebuilt`. |

## What goes into a deployment

The package is your project folder minus `.git`, `.vercel`, `node_modules`, virtual environments, `__pycache__`, `.DS_Store`, every `.env*` file and whatever `.vercelignore` lists (gitignore syntax, the same file Vercel reads). Use `.vercelignore` to keep test scripts and fixtures out:

```bash
printf 'test.py\nfixtures/\n' >> .vercelignore
```

Each deploy also keeps a copy of the project’s own source for the dashboard’s **Source** view (without dependencies, build output or files whose names suggest secrets, such as `*.pem` and `.npmrc`).

## Project names

- Lowercase letters, digits and dashes. The name becomes the production host: `<project>.<your domain>`.
- `www`, `api`, `app`, `docs`, `dashboard`, `admin`, `status` and `mail` are reserved.
- Names ending in a dash and 8 hex digits, or containing `-git-`, are refused, because they would look like another project’s deployment or branch URL.
- Rename a project with `forkrail project <name> --rename <new>` or under Settings → General. Its URLs, functions and logs keep the first name.

## New projects from the dashboard

**New project** in the dashboard makes a project three ways: import a GitHub repository (see [Deploy from GitHub](https://www.forkrail.com/docs/deploy-from-github)), give it a name only and deploy it from a terminal, or start from a template (FastAPI or a plain Node.js server) that builds and deploys to production at once.

---

# Deploy from GitHub

> Connect a project to a GitHub repository and every push deploys: the production branch to production, every other branch to a preview with its own URL and a pull request comment.

- Category: Deploy
- URL: https://www.forkrail.com/docs/deploy-from-github

## Connect a repository

1. **Give your install’s GitHub App access**

   Open the project’s **Settings → Git**. The first time, **Install on GitHub** takes you to GitHub, where you pick the account and either all repositories or only the ones you choose.

2. **Connect the repository**

   Back on Settings → Git, the repositories the app can read are listed, most recently pushed first. Click **Connect**.

3. **Check the production branch and root directory**

   The production branch is the repository’s default branch unless you change it. Set the root directory if the project lives in a subfolder of a monorepo.

Or start from the repository: **New project → Import**, name the project, pick the branch and root directory, paste any environment variables, and click **Deploy**. The production branch builds at once and you land on its build log.

**The same from a terminal (with the install’s AWS credentials)**

```bash
forkrail git repos                                # what the app can read
forkrail git connect shop acme/shop               # pushes to the default branch go to production
forkrail git connect shop acme/mono --branch release --root apps/shop
forkrail git connect shop acme/shop --create      # make the project from the repo and deploy it
forkrail git deploy shop                          # deploy the production branch's newest commit now
forkrail git disconnect shop
```

## What a push does

- GitHub sends a signed webhook to your dashboard. forkrail fetches that commit’s files and builds them in your builder exactly like `forkrail deploy`, with the project’s environment variables and build cache.
- The commit gets a status, `forkrail/<project>`: pending while it builds, then a link to the deployment or to the failed build’s log.
- GitHub is told about the deployment itself, which puts **View deployment** on the pull request.
- Two pushes to the production branch close together both build. If the older one finishes last, production stays on the newer one.
- Pushes from forks aren’t built.

## Branch URLs and pull request comments

Besides each deployment’s own URL, every branch gets an address that follows its newest ready preview: `<project>-git-<branch>.<your domain>`, with the branch lowercased and anything but letters and digits turned into dashes. `feature/Logs` becomes `shop-git-feature-logs.example.com`. A failed, canceled or skipped build leaves it where it was.

Every open pull request gets one comment per connected project, updated as the build goes: building, ready with the branch URL, failed with the step and a link to the log, canceled or skipped.

When a branch is deleted, usually after a merge, its previews are removed with their Lambda versions and its branch URL stops answering. Anything that has been production is kept as a rollback target.

## Monorepos

Connect one repository to several projects, each with its own root directory (`apps/web`, `services/api`). A push builds all of them. Dependencies install with the workspace’s package manager: the lockfile is found in the folders above the project, up to the repository’s top.

## Pushes that don’t deploy

Two `vercel.json` keys, read from the pushed commit, work as on Vercel:

**Turn off deploys for some branches**

```json
{
  "git": {
    "deploymentEnabled": { "dependabot/**": false, "wip-*": false }
  }
}
```

**Skip a build when a command exits 0**

```json
{
  "ignoreCommand": "[ \"$VERCEL_GIT_COMMIT_REF\" = docs ]"
}
```

- `git.deploymentEnabled: false` turns pushes off entirely; an object turns them off per branch pattern (`*` within a path segment, `**` across segments).
- `ignoreCommand` runs at the start of a push’s build. Exit 0 skips the build: it’s listed as canceled with the command’s output, and the commit status is a success so required checks don’t block a merge. A build has the commit’s files but not the git history, so `git diff HEAD^ HEAD` can’t be used yet.
- `github.autoJobCancelation` (on by default) cancels a branch’s older builds when a newer push arrives. `github.autoAlias: false` builds production deployments without putting them live.

## Deploy hooks

A deploy hook is a secret URL that builds a branch’s newest commit when called, for a CMS that publishes or a scheduled job. Create one under **Settings → Git → Deploy Hooks** or from the CLI. The URL is shown once.

```bash
forkrail deploy-hooks create shop "Sanity publish" --branch main   # prints the URL once
forkrail deploy-hooks ls shop
forkrail deploy-hooks rm shop 3f9a0c1b2d4e

curl -X POST "https://dashboard.example.com/api/deploy-hooks/shop/<secret>"
curl -X POST "https://dashboard.example.com/api/deploy-hooks/shop/<secret>?buildCache=false"
```

- A project can have 5 hooks, called 60 times an hour in all; beyond that the answer is `429` with `retry-after`.
- Calling a hook again for the same commit cancels the build it started before.
- Only the secret’s SHA-256 is stored. Anyone with the URL can deploy the branch, so treat it like a password.

## Limits

- A commit’s files may be up to 256 MB zipped.
- Git submodules and Git LFS files aren’t fetched.
- Builds get the commit’s files, never a GitHub token. The app’s private key is readable only by the control function and your AWS administrators.

---

# Deployments, promote and rollback

> Every deployment is immutable and keeps its own URL. Production can move to any of them in seconds: forward with Promote, back with Instant Rollback.

- Category: Deploy
- URL: https://www.forkrail.com/docs/deployments-and-rollbacks

## Deployment URLs

| URL | What it serves |
| --- | --- |
| `<project>-<id>.<domain>` | One deployment, forever (while it’s kept). |
| `<project>-git-<branch>.<domain>` | The newest ready preview of a branch. |
| `<project>.<domain>` and custom domains | Production. |

Each deployment is a published Lambda function version with its own files and routing rules, so it costs nothing while nobody opens it, and moving production between deployments never needs a rebuild.

## Promote, rollback or redeploy

| Action | Use it to | What happens |
| --- | --- | --- |
| **Instant rollback** | Undo a bad release | Production moves back to an earlier production deployment exactly as it was: code, environment variables and settings. Live in about five seconds. |
| **Promote** | Put a deployment live | A production deployment goes live instantly. A preview whose environment variables differ from production’s is published again with production’s first. |
| **Redeploy** | Pick up changed env vars or settings | A new deployment with the project’s current environment variables and settings, rebuilt from its source. |

```bash
forkrail ls my-app                      # deployments, newest first
forkrail rollback my-app                # back to the previous production deployment
forkrail rollback my-app --to <id>      # back to a given one
forkrail promote <id>                   # make a deployment production
forkrail redeploy <id>                  # rebuild with today's env vars and settings
forkrail redeploy <id> --prod           # ...as a production deployment
```

> **Promoting a preview:** A deployment keeps the environment variables it was built with. `forkrail promote` refuses a preview whose preview variables differ from production’s and names the variables (never their values). Use `forkrail redeploy <id> --prod`, which is what the dashboard’s Promote does in that case, or pass `--allow-preview-env` if you mean it. Next.js deployments are always rebuilt, since Next bakes variables into its build.

## Warm before it goes live

A new deployment has no running environments yet. Before production moves to it (a production deploy, a promote or a rollback), forkrail starts three environments in every region it runs in and lets your app start in each, without sending it a request (five with concurrent compute off). The first visitors then wait milliseconds instead of a cold start:

```text
==> warm-up in us-east-1: 3 of 3 environments ready in 1.6 s (3 new, the app started in 739 ms)
```

A warm-up never holds production back: if the app doesn’t start, the log warns and production moves anyway. A rollback moves production at once and warms meanwhile. To keep environments ready around the clock, see [keep warm](https://www.forkrail.com/docs/functions#keep-warm).

## Staged production deployments

Normally a production deployment goes live as soon as it’s ready. Turn off **Auto-assign custom domains** (Settings → Deployments) and every production deployment waits instead: it’s built with production’s variables, answers on its own URL for you to check, and goes live when you promote it.

```bash
forkrail project my-app --auto-assign-domains false   # true or default turns it back on
forkrail deploy --prod                                # staged: production is unchanged
forkrail promote <id>                                 # live in seconds, no rebuild

# Stage one deployment, whatever the setting
forkrail deploy --prod --skip-domain
```

Staged deployments are marked **Staged** in the deployments list, with a Promote button. Pushes to the production branch, redeploys and deploy hooks follow the setting too.

## How long deployments are kept

Like Vercel’s Deployment Retention, each kind of deployment has a period: **canceled**, **errored**, **preview** and **production**, 30 days each unless you change it (from `1d` up to ten years, or `unlimited`). Set the install’s default under Team Settings → Deployments, and a project’s own under its Settings → Deployments.

Some deployments are kept whatever their age: production, the project’s 10 newest, its 20 newest ready production deployments and 20 newest ready previews, the last 5 that served production (rollback targets), anything still building, the newest preview of every branch that still exists, and anything a domain points at.

```bash
forkrail retention --project my-app              # what the policy does with each deployment, and why
forkrail retention set --project my-app --preview 7d --production 1y --dry-run
forkrail retention set --production 1y            # the install's default
forkrail retention sweep --project my-app         # list what a run would delete; --yes to run it
```

### Delete and restore

Deleting is in two steps, as on Vercel. A deleted deployment stops answering at once and moves to the project’s **Recently deleted** list with everything still stored. Restore it within 30 days and it comes back exactly as it was, at its own URL. After that it’s deleted for good.

```bash
forkrail rm <id>                      # delete a deployment that isn't production
forkrail restore <id>                 # bring it back
forkrail rm --project my-app          # delete a whole project (asks for the name)
```

Deleting a project removes everything of it: its deployments, functions in every region, files, schedules, environment variables and domains. Request logs already written are kept.

---

# Frameworks

> Websites build through each framework’s own Vercel adapter, with no change to your code or config. Static sites need no server at all.

- Category: Deploy
- URL: https://www.forkrail.com/docs/frameworks

## Supported frameworks

Run `forkrail deploy` in the project. forkrail finds the framework in `package.json` (or `vercel.json`’s `framework`, or the project’s setting), installs dependencies with your lockfile’s package manager, and runs the build with Vercel’s build variables. A framework with a server writes Vercel’s Build Output (`.vercel/output`) through its own adapter, and forkrail deploys that.

| Framework | Status | What the project needs |
| --- | --- | --- |
| SvelteKit | Production ready | `@sveltejs/adapter-vercel` or `adapter-auto`. With `adapter-static` it’s a static site. |
| Astro | Production ready | `@astrojs/vercel` for a server; nothing for a static site. |
| Nuxt, Nitro, Vite + Nitro | Production ready | Nothing: Nitro picks its `vercel` preset. |
| TanStack Start | Production ready | Nitro’s Vite plugin (`nitro()` in `vite.config`). |
| React Router 7+ | Production ready | Vite; `vercelPreset()` from `@vercel/react-router` for a function per route config. |
| Remix 2 | Production ready | Vite; `vercelPreset()` from `@vercel/remix`. |
| Vite, CRA, Vue CLI, Angular, Docusaurus, VitePress, Eleventy, Gatsby, Hugo | Production ready | Nothing: deployed as a static site. |
| Next.js 13.5 to 16 | Beta | Nothing. Read [Next.js](#nextjs) below before putting one in production. |

## What works with each

| Framework | SSR | Streaming | ISR | Images | Middleware | Skew protection | Crons |
| --- | --- | --- | --- | --- | --- | --- | --- |
| SvelteKit | Yes | Yes | `config.isr` | Adapter `images` | Yes | Yes | `vercel.json` |
| Astro | Yes | Yes | Adapter `isr` | `imageService` | Yes | Yes | `vercel.json` |
| Nuxt | Yes | Whole pages, as on Vercel | `isr` route rules | Nuxt Image | Yes | Yes | `vercel.json` |
| TanStack Start, Nitro | Yes | Yes | `isr` route rules | `vercel.json` | Yes | Yes | `scheduledTasks`, `vercel.json` |
| React Router | Yes | Yes | No, as on Vercel | `vercel.json` | Yes | Yes | `vercel.json` |
| Remix 2 | Yes | Yes | No, as on Vercel | `vercel.json` | Yes | No, as on Vercel | `vercel.json` |
| Static sites | n/a | n/a | n/a | `vercel.json` | Yes | n/a | n/a |
| Next.js (beta) | Yes | Yes | Its own, shared cache | Its own optimizer | Yes | Yes | `vercel.json` |

- **Images** is Image Optimization (`/_vercel/image`). See [Image Optimization](https://www.forkrail.com/docs/image-optimization).
- **Middleware** is the project’s `middleware.ts` or `vercel.json` `proxy`. See [Routing Middleware](https://www.forkrail.com/docs/middleware).
- **ISR** pages are kept by the router and shared by every worker. See [Caching and ISR](https://www.forkrail.com/docs/caching).
- A deployment’s functions all run in **one Lambda function** at the largest memory any of them asks for, where Vercel runs each on its own. One route asking for 1,024 MB makes every route 1,024 MB.

## SvelteKit and Astro

Form actions, hooks, `$env`, Astro actions, server islands and redirects work as on Vercel. `getClientAddress()` and `Astro.clientAddress` return the visitor’s real address. Astro’s sessions need a driver you name, on Vercel too. Astro’s `edgeMiddleware` runs on Node, as every Edge function does here.

## Nuxt, Nitro and TanStack Start

- Route rules are answered by the router before the function wakes: `redirect`, `headers`, `proxy`, `isr` and Nuxt’s `swr`.
- Static files are served before the function with Nitro’s cache headers (a year, `immutable`, for hashed assets).
- Nitro 3’s `scheduledTasks` become cron jobs, as on Vercel. Nitro 2’s (Nuxt 4) don’t; use `crons` in `vercel.json`.
- A project that pins the `node-server` preset runs as one server, and the build warns that route rules and ISR then run inside it. Remove the pin to get Vercel’s behavior.

## React Router and Remix

With `vercelPreset()`, routes whose `config` (`memory`, `maxDuration`) differ get their own function bundle; without it one function serves every route. SPA mode (`ssr: false`) is a static site. pnpm and Yarn projects install into a flat `node_modules`. Routes on the Edge runtime are refused: remove `runtime: "edge"` to run them on Node.

## Next.js (beta)

> **Beta:** Next.js 13.5 to 16 (App Router and Pages Router) builds, deploys and answers every route as `next start` would, with one cache shared by all workers. It isn’t recommended for critical production yet.

- forkrail runs Next’s own standalone server as the deployment’s function. Your `package.json` and `next.config` aren’t changed.
- Next’s caches (pages, route handlers, `fetch`, `unstable_cache`, `'use cache'`) live in the router, so a page regenerated by one worker is served by all, and `revalidatePath` / `revalidateTag` reach every worker.
- Prerendered pages are served by the router from its cache (`x-vercel-cache: HIT`), static files from `/_next/static/` with a one-year immutable cache, and `/_next/image` by the install’s image function.
- Middleware runs first: requests your middleware may match always go to Next.
- `output: 'export'` deploys as a static site with no function.
- Refused: Next before 13.5, Yarn Plug’n’Play, and servers over 250 MB unzipped.
- Known gap: on Next 13.5 to 14.2, background regeneration of a stale page can be cut off when the worker retires; 15 and later are fine.

## Static sites

A site with no server deploys as files alone: no function, nothing to start, nothing billed but storage and transfer. The router serves every file from S3 in its own region and keeps the busiest in memory.

- A framework’s build output is found automatically: `dist`, `build`, `_site`, `public`, `docs/.vitepress/dist` or Angular’s `dist/<project>/browser`. `outputDirectory` names another.
- Without a framework, `public/` is served if there is one, else the folder itself (without hidden files, `node_modules`, `README.md`, `package.json` and lockfiles).
- `/docs` and `/docs/` both serve `docs/index.html`. A missing path gets your `404.html` with status 404.
- Files are revalidated on every visit (`max-age=0` and a 304) unless your `headers` say otherwise; hashed assets of known frameworks are cached for a year.
- A single-page app built with Vite needs a rewrite to `index.html`, as on Vercel: `{ "source": "/(.*)", "destination": "/index.html" }`.

## Not supported yet

These are refused by name, so a build stops rather than deploy something that behaves differently:

- Astro with a non-Vercel adapter, SvelteKit without Vercel’s or the static adapter, TanStack Start without Nitro, other Nitro presets.
- Remix’s classic compiler (without Vite), React Router without a `vite.config`.
- Jekyll and Middleman (the builder has no Ruby) and Zola (no arm64 build for the builder’s Linux).
- In a Build Output: `services`, Python functions, more than 250 MB of functions, and routes with `locale`.

Not yet compared with Vercel, so not claimed: SolidStart, Analog, Qwik City, Gatsby SSR/DSG pages, Mastra and RedwoodJS.

---

# Python, Node.js, Go and Rust

> APIs deploy with no configuration, the way Vercel finds them: forkrail detects the framework, the entry file and the language version from your project.

- Category: Deploy
- URL: https://www.forkrail.com/docs/languages

## Python

FastAPI, Flask, Django, FastHTML, or any ASGI or WSGI app.

- **Entry:** the first of `app.py`, `index.py`, `server.py`, `main.py`, `wsgi.py`, `asgi.py` (at the top, then in `src/`, `app/` and `api/`) that defines `app`, `application` or `handler`. Or set `[tool.vercel] entrypoint = "module:app"` in `pyproject.toml`. Django’s comes from `manage.py`.
- **Dependencies:** `pyproject.toml` (pinned by `uv.lock`), `Pipfile.lock`, `Pipfile` or `requirements.txt`.
- **Version:** `.python-version`, else `requires-python`, else `Pipfile.lock`. Lambda runs 3.12, 3.13 and 3.14; a project that names none runs 3.13.
- WSGI apps (Flask, Django) run in 10 threads; ASGI apps run `async` routes on their event loop.
- Django: `collectstatic` runs at build time when `STATIC_ROOT` is set, and the router serves the files. Add your hosts to `ALLOWED_HOSTS`.

**api/main.py**

```ts
from fastapi import FastAPI

app = FastAPI()

@app.get("/api/hello")
def hello():
    return {"hello": "world"}
```

## Node.js

Express, Hono, Fastify, Koa, NestJS, Elysia, H3, or any `server.*` file.

- **Entry:** the first of `app`, `index`, `server`, `src/app`, `src/index`, `src/server` (NestJS: `src/main`) with a `.js`, `.mjs`, `.cjs`, `.ts`, `.mts` or `.cts` extension that imports the framework, else `package.json`’s `main`.
- The app may listen on `PORT` or export itself (`export default app`); both work, as on Vercel.
- **Version:** `engines.node`. Lambda runs Node 24 (the default) and 22.
- Dependencies install with the project’s package manager, and its `vercel-build` or `build` script runs. TypeScript is bundled with esbuild.

**server.ts**

```ts
import { Hono } from 'hono'

const app = new Hono()
app.get('/', (c) => c.json({ ok: true }))

export default app
```

## Functions in api/

Vercel’s zero-config functions work the same way: every file in `api/` is a function, served at its path without the extension.

- `api/hello.ts` answers `/api/hello`; `api/index.ts` answers `/api`; `api/users/[id].ts` answers `/api/users/<id>` with `id` in the query.
- Node handlers take both of Vercel’s shapes: `export default function handler(req, res)` with `req.query`, `req.body`, `res.json()` and friends, or Web handlers like `export function GET(request)` returning a `Response`.
- Python files that define `app` (ASGI or WSGI) or a `handler` class are functions; other `.py` files are modules.
- Files and folders starting with `_` or `.` aren’t functions.
- Every function in a project runs on one language’s runtime. Node and Python functions in the same project, or functions beside a server, are refused for now.

**api/hello.ts**

```ts
export function GET(request: Request) {
  return Response.json({ hello: new URL(request.url).searchParams.get('name') ?? 'world' })
}
```

## Go and Rust

- **Vercel’s layout:** each file in `api/` is a function. Go files export one `func(http.ResponseWriter, *http.Request)`. Rust files are `[[bin]]` targets written with the `vercel_runtime` crate, unchanged.
- **A web server:** a Go `main` package (`main.go`, `cmd/api/main.go`, `cmd/server/main.go`) or a Rust binary (axum, actix) that listens on `PORT`.
- Go builds with `CGO_ENABLED=0`; the `go` line of `go.mod` picks the toolchain. Rust builds with `cargo zigbuild --release` for Amazon Linux 2023.
- Both run on Lambda’s `provided.al2023` runtime on arm64, and their module and target caches are kept between builds.

## Choosing the preset yourself

Detection is automatic. To override it, set the preset under Settings → Build, with `forkrail project NAME --framework SLUG` (Vercel’s names: `flask`, `django`, `express`, `hono`, `go`, `rust`, `vite` and so on), or with `framework` in `vercel.json`, which wins.

---

# Environment variables

> Variables per environment and per branch, encrypted with a KMS key in your own AWS account. Production and preview values are never shown again once saved.

- Category: Deploy
- URL: https://www.forkrail.com/docs/environment-variables

## Three environments

| Environment | Used by | Values readable? |
| --- | --- | --- |
| Production | Production deployments | No: write-only, never shown or printed again |
| Preview | Every other deployment (with optional per-branch values) | No: write-only |
| Development | Your own machine, through `forkrail env pull` or `env run` | Yes, for developers and above |

Changes apply to the next deploy or redeploy, never to deployments that already exist. That’s what [Redeploy](https://www.forkrail.com/docs/deployments-and-rollbacks#promote-rollback-redeploy) is for.

## Add and remove variables

In the dashboard, open the project’s **Environment variables** page. You can paste a whole `.env` file into the key field to fill in many at once. From the CLI, values come from stdin or a prompt and are never printed:

```bash
# Production and previews (the default without --target)
forkrail env add my-app DATABASE_URL

# One environment, from stdin
printf '%s' "$STRIPE_KEY" | forkrail env add my-app STRIPE_SECRET_KEY --target production

# Several at once
forkrail env add my-app API_URL --target preview,development

forkrail env ls my-app                  # names only
forkrail env rm my-app API_URL --target preview
```

`--target` (also `-e` or `--environment`) takes `production`, `preview`, `development`, or several comma-separated.

## Values for one branch

A preview variable can be set for one Git branch, as on Vercel. That branch’s previews get its value instead of the preview value of the same name, and every other preview variable as usual.

```bash
forkrail env add my-app API_URL --git-branch feature/checkout
forkrail env rm my-app API_URL --git-branch feature/checkout
```

The branch is the one a deployment was made from: a push’s branch, or the branch checked out when you ran `forkrail deploy`. Production deployments never get branch values.

## Local development

```bash
forkrail env pull                               # Development values into .env.local
forkrail env pull .env --environment preview    # another file and environment
forkrail env run -- npm run dev                 # run a command with the values, no file written
```

An existing file is merged after you confirm (`--yes` in scripts). A new file is readable only by you, and the CLI warns when git doesn’t ignore it. Production and preview values can’t be read back, so they’re written empty for you to fill in.

## System variables

Every deployment is told about itself, under Vercel’s names, so code moved from Vercel finds what it expects:

| Variable | Value |
| --- | --- |
| `VERCEL` | `1` |
| `VERCEL_ENV`, `VERCEL_TARGET_ENV` | `production` or `preview` |
| `VERCEL_URL` | The deployment’s own host |
| `VERCEL_BRANCH_URL` | The branch URL of a branch preview |
| `VERCEL_PROJECT_PRODUCTION_URL` | The production host |
| `VERCEL_REGION` | Where it runs, as Vercel names it (`iad1`, `fra1`…) |
| `VERCEL_DEPLOYMENT_ID`, `VERCEL_PROJECT_ID`, `VERCEL_PROJECT_NAME` | The deployment’s id and the project’s name |
| `VERCEL_GIT_COMMIT_SHA`, `_REF`, `_MESSAGE`, `_AUTHOR_NAME`, `_REPO_OWNER`, `_REPO_SLUG`, `_PULL_REQUEST_ID` | The commit, for deployments made from Git |
| `FORKRAIL_ENV`, `FORKRAIL_URL`, `FORKRAIL_REGION` (AWS name), `FORKRAIL_DEPLOYMENT_ID`, `FORKRAIL_PROJECT_NAME` | forkrail’s own names for the main ones |

Builds get the same, plus `CI=1` and `VERCEL_GIT_PREVIOUS_SHA`. Node apps run with `NODE_ENV=production`, previews too, as on Vercel. A variable you set yourself wins over a system variable of the same name. `VERCEL_OIDC_TOKEN` isn’t set; give the project an [IAM role](https://www.forkrail.com/docs/functions#iam-role) instead.

## Names and limits

- Names are letters, digits and `_`, not starting with a digit.
- Reserved: `AWS_LAMBDA_*`, `FORKRAIL_*`, `PATH`, `HOME`, `TEMP`, `TZ`, `PYTHONPATH` and a few of Lambda’s own. You may set the AWS SDK’s `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_SESSION_TOKEN` and `AWS_REGION`, as Vercel allows.
- Up to **64 KB per environment**, names and values together, as on Vercel. One value can take all of it.

Lambda’s own environment holds only 4 KB. When a deployment’s variables don’t fit, forkrail seals them in an encrypted (AES-256-GCM) file with a key made for that deployment, and your app reads them as usual. Nothing changes for your code.

## Where values are kept

Each value is an AWS SSM SecureString parameter, encrypted with forkrail’s own KMS key in your account. Only identities you allow to decrypt with that key can read a value: the control function and your administrators. The routers, the dashboard and your apps can’t. Values are masked in build logs. The key costs $1 a month; the parameters are free.

Who can change what: developers change preview and development variables; members and owners change production’s too; viewers see names only. See [Team and roles](https://www.forkrail.com/docs/team-and-sign-in).

---

# Domains

> Serve production on your own domain, apex or wildcard, with a Let’s Encrypt certificate the router gets and renews by itself. Domains can also follow a branch or redirect.

- Category: Deploy
- URL: https://www.forkrail.com/docs/domains

## Add a domain

Open the project’s **Domains** page, or use the CLI. `add` prints the DNS records the domain needs.

```bash
forkrail domains add shop.example.com storefront                 # a subdomain
forkrail domains add example.com storefront                      # the apex
forkrail domains add '*.example.com' storefront                  # a wildcard
forkrail domains add www.example.com storefront --redirect example.com --status 308
forkrail domains add staging.example.com storefront --branch staging

forkrail domains ls storefront          # each domain and its certificate
forkrail domains inspect shop.example.com
forkrail domains check shop.example.com # look at DNS again now
forkrail domains update www.example.com --production
forkrail domains rm shop.example.com
```

## DNS records

| Record | For |
| --- | --- |
| `shop.example.com CNAME storefront.<your forkrail domain>` | A subdomain |
| `example.com A <the install’s address>` | The apex (`@`), which can’t be a CNAME |
| `_acme-challenge.shop.example.com CNAME <hash>._acme.<your forkrail domain>` | Optional: the certificate before DNS moves. Required for a wildcard. |

> **On Cloudflare, turn the proxy off:** The record must be **DNS only** (grey cloud). A proxied record shows `invalid (proxied)`, because the router needs to see the visitor and answer the certificate challenge itself.

## Certificates

The router gets each domain a Let’s Encrypt certificate, proving the domain is yours the first way that works:

1. **Cloudflare:** the domain is in a Cloudflare zone your install’s token can edit. The certificate arrives within a minute.
2. **Delegated challenge:** `_acme-challenge.<domain>` is a CNAME to the address `add` printed. This works before the domain points at forkrail, and it’s the only way a wildcard gets a certificate.
3. **HTTP:** the domain already points at forkrail.

Before asking Let’s Encrypt, the router checks the domain’s own nameservers, so a domain whose DNS isn’t ready yet never wastes a validation attempt. It looks again every 30 seconds (every 5 minutes after a day); with the Domains page open it checks every few seconds. Certificates renew with a third of their 90 days left, and you’re emailed if one has under 14 days left.

## Redirect domains and branch domains

- **Redirects:** a domain can redirect (301, 302, 307 or 308) to another of the project’s domains, keeping the path and query. The dashboard offers the `www` pair whenever you add an apex domain.
- **Branches:** a domain with `--branch staging` serves the newest ready preview of that branch, like its branch URL, and moves with each push. It answers 404 until the branch has a ready preview.
- **Wildcards:** `*.example.com` covers one label below the domain.

## Move a domain without downtime

1. **Add the domain**

   On a Cloudflare zone your token edits, the certificate comes within a minute. Elsewhere, add the `_acme-challenge` CNAME it printed first.

```bash
forkrail domains add api.example.com my-api
```

2. **Wait for the certificate**

   Until `domains ls` shows `issued`.

```bash
forkrail domains ls my-api
```

3. **Test it before DNS moves**

   Send a request straight to the router while DNS still points at the old host.

```bash
curl --resolve api.example.com:443:<router address> https://api.example.com/health
```

4. **Lower the TTL**

   Set the record’s TTL to 60 seconds, keeping its target, and wait out the old TTL.

5. **Point the record at forkrail**

   Change the CNAME to `<project>.<your forkrail domain>`. To go back, point it at the old host again.

`forkrail domains rm` stops serving a domain within seconds, so move its DNS away first. Owners and members change domains; developers can ask for a check.

---

# Cron jobs and schedules

> Call your production deployment on a schedule with `crons` in `vercel.json`, or with named schedules that have their own time zone, method and jitter.

- Category: Deploy
- URL: https://www.forkrail.com/docs/cron-schedules

## Define a schedule

**vercel.json**

```json
{
  "crons": [
    { "path": "/api/cron/sync", "schedule": "0 5 * * *" }
  ],
  "schedules": {
    "daily-report": {
      "schedule": "0 9 * * 1-5",
      "path": "/api/report",
      "requestMethod": "GET",
      "timezone": "America/New_York",
      "jitter": 5
    }
  }
}
```

- `crons`: a GET to `path`, in UTC, within the minute.
- `schedules`: a named schedule with its own IANA `timezone` (UTC by default), `requestMethod` (`GET` or `POST`, POST by default) and `jitter` (1 to 15 minutes; the run starts somewhere in that window).
- Expressions have five fields (minute, hour, day of month, month, day of week with Sunday = 0) using digits, `*`, `,`, `-` and `/`. Names like `MON` aren’t accepted.
- Up to 100 a project, both keys together. Frameworks that define crons (Nitro 3’s `scheduledTasks`) are merged in.

## Secure the endpoint

The path is public, so check who’s calling. Set a `CRON_SECRET` environment variable and every run sends `Authorization: Bearer <CRON_SECRET>`:

**api/cron/sync.ts**

```ts
export function GET(request: Request) {
  if (request.headers.get('authorization') !== `Bearer ${process.env.CRON_SECRET}`) {
    return new Response('Unauthorized', { status: 401 })
  }
  // ...do the work
  return Response.json({ ok: true })
}
```

## How runs work

- Only production runs schedules. A deploy, promote or rollback brings the schedules of whichever deployment is production now.
- Each run is a request to production, logged like any other, with no retries. Redirects aren’t followed and the deployment’s `maxDuration` applies.
- Runs that overlap aren’t stopped. A run can (rarely) arrive twice or be skipped, so make the handler safe to run twice.
- A run that can’t start on time starts late, up to its jitter plus the time between runs; later than that it’s skipped and logged. Monthly and yearly crons never expire.
- Schedules run on AWS EventBridge Scheduler in your account. Each run costs what a request to your function costs.

## Run, pause and resume

```bash
forkrail schedules ls my-app                  # state and next runs (alias: forkrail crons)
forkrail schedules run my-app daily-report    # run now, whatever its state
forkrail schedules disable my-app --all       # stays off across deploys and rollbacks
forkrail schedules enable my-app daily-report
```

The dashboard’s **Schedules** page does the same and lists each schedule’s runs; the Logs page filters by schedule. Everyone on the team can see schedules; members and owners run and change them.

---

# Function settings

> Memory, maximum duration, keep warm, worker caps and IAM roles: what each setting does, where to set it, and what it costs.

- Category: Functions
- URL: https://www.forkrail.com/docs/functions

## The settings

| Setting | Default | Range | Applies |
| --- | --- | --- | --- |
| Memory | 640 MB | 128 to 10,240 MB | Next deploy or redeploy |
| Max duration | 300 seconds | 1 to 900 seconds | Next deploy or redeploy |
| Concurrent compute | On | On or off | Next deploy or redeploy |
| Max requests per instance | 10 | 2 to 50 on each worker | Within seconds |
| Keep warm | Off | 0 to 20 environments per region, or automatic | Within seconds |
| Max workers | No cap | 1 to 1,000 per deployment | Within seconds |
| Regions | Your install’s region | Any of 20 AWS regions | Next deploy or redeploy |

Change them under the project’s **Settings → Functions**, or from the CLI:

```bash
forkrail project my-api                                   # show the settings
forkrail project my-api --memory 1024 --max-duration 60    # 'default' clears one
forkrail project my-api --concurrent false                 # one request per worker
forkrail project my-api --keep-warm 2                      # or auto, or 0
```

## Which value wins

For memory, max duration and concurrent compute, the first of these that sets a value wins:

1. The deploy’s own flag: `forkrail deploy --memory 1024` (that deployment only; a redeploy doesn’t keep it).
2. The deployment’s `vercel.json`: `functions` patterns and `fluid`.
3. The project’s settings.
4. forkrail’s defaults: 640 MB, 300 seconds, concurrent compute on.

**vercel.json**

```json
{
  "functions": {
    "api/**/*.py": { "memory": 1024, "maxDuration": 60 },
    "api/report.ts": { "maxDuration": 300 }
  }
}
```

All of a deployment’s functions run in one Lambda function, which gets the largest memory any of them asks for. Each still keeps its own `maxDuration`, which the router enforces per request.

## Memory and CPU

Memory also buys CPU: Lambda gives a full core at 1,769 MB and a proportional share below that. Lambda bills by memory × time, so the right size depends on what your function spends its time doing.

- **Mostly waiting** on a database or other APIs: small is fine. Such an API runs about as fast at 256 MB as at 640 MB, for 40% of the price.
- **CPU-heavy**, like server-side rendering or image work: more memory finishes sooner. 1,024 MB buys 0.58 of a core where 640 MB buys 0.36.
- Cold starts don’t get slower at small sizes.

> **New AWS accounts:** Some new accounts can give a function only 512 MB at first. forkrail sizes every function to fit, the deployment’s log says so, and the dashboard shows the limit under Infrastructure and in Settings → Functions. AWS raises it as the account is used, or sooner through a free support case.

## Max duration

A request that runs longer than its function’s `maxDuration` gets `504 FUNCTION_INVOCATION_TIMEOUT` and its stream is cut. The ceiling is 900 seconds (15 minutes), Lambda’s own. Responses stream as they’re written, so a long response starts reaching the visitor right away.

Need to keep working after the response? `waitUntil()` from `@vercel/functions` keeps the worker open until the promise settles, as on Vercel.

## Keep warm

Lambda drops an environment after a few idle minutes, and the next request waits for a new one to start (a second or more for a framework’s server). Keep warm has the routers keep a number of environments ready for the project’s production deployment, in every region it runs in, so a request after a quiet spell doesn’t wait.

```bash
forkrail project my-app --keep-warm 2       # two environments per region
forkrail project my-app --keep-warm auto    # as many as were busy at once at the last day's peak
forkrail project my-app --keep-warm 0       # off (the default)
```

- The router sends a keep-alive every 2 minutes, which never reaches your app. Real traffic counts in its place.
- It costs about **$0.011 a month per environment at 1 GB**, shown in the dashboard as you choose.
- A deployment with no visitors for 7 days is paused until its next request.
- Separately from keep warm, every new production deployment is [warmed before it goes live](https://www.forkrail.com/docs/deployments-and-rollbacks#warm-up).

## Workers and AWS concurrency

A deployment may run as many workers as your AWS account’s Lambda concurrency allows, shared with everything else in the account. What counts is requests in flight: 100 requests a second at 1 to 2 seconds each is 100 to 200 at once (fewer workers with concurrent compute). Past the account’s limit, requests wait up to 15 seconds for a worker, then get `503`.

Cap one project so it can’t take the whole account:

```bash
forkrail limits my-api --max-workers 300   # applies within seconds, no redeploy
forkrail limits my-api                     # show it
forkrail limits my-api --max-workers default
```

The dashboard’s **Infrastructure** page shows how many functions can run at once in each region. Raise the account’s limit in AWS Service Quotas (Lambda → Concurrent executions).

## Calling AWS from your app

On Vercel you’d put access keys in environment variables. Your forkrail app already runs in your AWS account, so give its project an IAM role instead, and the AWS SDK picks it up with no keys at all:

```bash
forkrail project my-app --role my-app-role    # by name or ARN; needs the install's AWS credentials
forkrail project my-app --role default        # back to the shared forkrail-worker role
```

The role applies from the next deploy. It’s the way to reach S3, DynamoDB, SQS, Bedrock or RDS from your app, and replaces Vercel’s OIDC federation.

## Request limits

- **Request bodies** up to about 4.5 MB, as on Vercel. Larger ones get `413 FUNCTION_PAYLOAD_TOO_LARGE` before any function runs. Responses have no size limit: they stream.
- **Headers:** one header over 32 KB gets `494`; more than 500 headers, or about 127.5 KB in all, gets `431`.
- **Loops:** when calls between your own deployments nest more than 5 deep, or one chain makes more than 1,000 such calls, the next gets `508 INFINITE_LOOP_DETECTED`. A page calling its own API is never affected.

See [Limits](https://www.forkrail.com/docs/limits) and [Error codes](https://www.forkrail.com/docs/errors) for the full lists.

---

# Function regions

> Run a project’s functions next to its database. Pick one region or several, by Vercel’s names or AWS’s, with no router needed in that region.

- Category: Functions
- URL: https://www.forkrail.com/docs/function-regions

## Pick regions

A new project’s functions run in your install’s home region. Pick others where the function’s database or the APIs it calls are, so each call stays short:

```bash
forkrail project my-api --regions iad1               # Vercel's names or AWS's (us-east-1)
forkrail project my-api --regions us-east-1,fra1     # several: each visitor gets the nearest
forkrail project my-api --regions default            # no setting: where production runs now
```

Or in `vercel.json`, which wins over the project’s setting, as on Vercel: `"regions": ["fra1"]`. The dashboard has it under **Settings → Functions → Regions**. It applies from the next deploy or redeploy.

The first time a project picks a region, forkrail sets it up: a code bucket and an encryption key there (about $1 a month). `forkrail regions setup eu-central-1` does it ahead of time, and `forkrail regions ls` lists the regions in use.

## Available regions

| Vercel code | AWS region | Location |
| --- | --- | --- |
| `iad1` | `us-east-1` | Washington, D.C., USA |
| `cle1` | `us-east-2` | Cleveland, USA |
| `sfo1` | `us-west-1` | San Francisco, USA |
| `pdx1` | `us-west-2` | Portland, USA |
| `yul1` | `ca-central-1` | Montréal, Canada |
| `gru1` | `sa-east-1` | São Paulo, Brazil |
| `fra1` | `eu-central-1` | Frankfurt, Germany |
| `dub1` | `eu-west-1` | Dublin, Ireland |
| `lhr1` | `eu-west-2` | London, UK |
| `cdg1` | `eu-west-3` | Paris, France |
| `arn1` | `eu-north-1` | Stockholm, Sweden |
| `bom1` | `ap-south-1` | Mumbai, India |
| `sin1` | `ap-southeast-1` | Singapore |
| `syd1` | `ap-southeast-2` | Sydney, Australia |
| `hnd1` | `ap-northeast-1` | Tokyo, Japan |
| `icn1` | `ap-northeast-2` | Seoul, South Korea |
| `kix1` | `ap-northeast-3` | Osaka, Japan |
| `hkg1` | `ap-east-1` | Hong Kong (opt-in region) |
| `cpt1` | `af-south-1` | Cape Town, South Africa (opt-in region) |
| `dxb1` | `me-central-1` | Dubai, UAE (opt-in region) |

Opt-in regions must be turned on for your AWS account first (AWS console → Account → AWS Regions).

## How requests reach them

Visitors reach the router. The router runs the function in its own region if the project has one there; otherwise in the nearest region the project picked. In a region with no router, the router invokes the function there directly and the worker dials back to it.

Firewall, rate limits, the cache and the access log stay with the router the visitor reached, so a function region changes only where your code runs. Pick one region when the function’s data is in one place (a request’s calls to the database outweigh one hop between regions), and a region near each group of visitors when it isn’t.

> **Cost of crossing regions:** Traffic between the router and a function in another region costs $0.02 per GB instead of $0.01, and stays on AWS’s own network. Vercel bills the same trip as Fast Origin Transfer. [Spend limits](https://www.forkrail.com/docs/spend-budgets) count it.

---

# Concurrent compute

> The router sends several requests at once to one warm worker, so an API that spends its time waiting on a database pays for one environment instead of ten.

- Category: Functions
- URL: https://www.forkrail.com/docs/concurrent-compute

## How it works

Classic serverless runs one request per environment. Ten requests in flight means ten environments billed, even when nine of them are waiting on a Postgres query. With concurrent compute (on by default), a running worker takes up to **10 requests at once** over its connection to the router. When every worker is full, the router starts another, as many as traffic needs.

- The router learns how much memory each route’s requests use and adds a request to a busy worker only when it fits.
- If a new worker hasn’t connected within about 100 ms, the router starts a second one in parallel, so one slow cold start doesn’t hold a request.
- Idle workers retire as soon as keeping them costs more than starting a new one, and every worker is replaced after 13 minutes.

It’s forkrail’s version of what Vercel calls fluid compute, and it reads Vercel’s `fluid` key in `vercel.json`.

## Max requests per instance

Ten is the default. Set anywhere from 2 to 50 under **Settings → Functions → Concurrent compute**, where the dashboard offers about one per 50 MB of memory (15 at 768 MB, 50 from 2,560 MB). It applies within seconds, without a redeploy.

```bash
forkrail project my-api --max-inflight 3        # 2 to 50
forkrail project my-api --max-inflight default  # back to 10
```

> **A limit per worker, not per project:** This number caps how many requests share **one** worker. It doesn’t limit the project: there’s no cap on requests per second, and when every worker is full the router starts another. How many workers run at once is bounded only by your AWS account’s Lambda concurrency quota (1,000 per region by default, lower on some new accounts; AWS raises it on request), by a cap you choose with [`forkrail limits --max-workers`](https://www.forkrail.com/docs/functions#max-workers) (none by default), and by a [spend limit](https://www.forkrail.com/docs/spend-budgets) pause. A worker can also take fewer requests than the setting while its CPU is busy.

Fewer means fewer requests share each environment and its outbound IP address, and more workers start under load. A Python WSGI app (Flask, Django) runs at most 10 requests at once per worker whatever the setting. An ASGI app (FastAPI) runs `async` routes on one event loop, so a blocking call in one route holds up the others.

## One request per worker

Some APIs need each request in its own environment, for strict isolation or so that concurrent requests leave from different IP addresses. Turn concurrent compute off, in order of precedence:

```bash
# For one deploy
forkrail deploy --concurrent false

# In vercel.json (Vercel reads the same key)
#   { "fluid": false }

# As the project's setting
forkrail project my-api --concurrent false
```

Prefer `vercel.json` or the project setting: a later deploy without the flag would turn concurrent compute back on. The CLI warns when a deploy or promote would replace a one-request-per-worker production deployment with a concurrent one. Off, it bills about what classic Lambda does.

## What it saves

Lambda bills each worker from start to finish. Requests that overlap on one worker share that time:

|  | One request per worker | Concurrent compute |
| --- | --- | --- |
| 10 requests, 1 s each, all at once, 640 MB | 10 workers × 1 s = 6.25 GB-s | 1 worker × ~1 s = 0.625 GB-s |
| Invocations | 10 | 1 |
| Outbound IPs | 10 | 1 |

The saving is largest for I/O-bound work (APIs calling databases, other APIs or LLMs). CPU-bound requests gain less, because they compete for the same CPU.

---

# Redirects, rewrites and headers

> Route requests with `vercel.json` as you would on Vercel, keep up to a million bulk redirects, and change routing rules without a redeploy.

- Category: Routing and caching
- URL: https://www.forkrail.com/docs/routing

## What runs, in order

Every request to a project goes through the same steps. The project’s **Routing** page in the dashboard draws them for your project, with links to each.

1. The [firewall](https://www.forkrail.com/docs/firewall) and [deployment protection](https://www.forkrail.com/docs/deployment-protection).
2. [Bulk redirects](#bulk-redirects): the project’s own, then the deployment’s.
3. [Routing rules](#routing-rules), the project’s rules that change without a redeploy.
4. The deployment’s `vercel.json`: `cleanUrls` and `trailingSlash`, then `redirects`, then `headers`.
5. [Middleware](https://www.forkrail.com/docs/middleware), on the paths it matches.
6. The deployment’s files, then its `rewrites`, then its functions.

## Routing in vercel.json

Every routing key of `vercel.json` works as it does on Vercel, for APIs, websites and static sites alike: `redirects`, `rewrites`, `headers`, `cleanUrls`, `trailingSlash`, and the older `routes`. A `vercel.toml` or `vercel.ts` works in its place (one of them per project).

**vercel.json**

```json
{
  "cleanUrls": true,
  "trailingSlash": false,
  "redirects": [
    { "source": "/old-blog/:slug", "destination": "/blog/:slug", "permanent": true }
  ],
  "rewrites": [
    { "source": "/app/:path*", "destination": "/app/index.html" },
    { "source": "/api/:path*", "destination": "https://api.example.com/:path*" }
  ],
  "headers": [
    { "source": "/(.*)", "headers": [{ "key": "X-Frame-Options", "value": "DENY" }] }
  ]
}
```

### Patterns and conditions

Patterns are Vercel’s: `/blog/:slug`, `/docs/:path*`, `/(.*)`, inline regexes such as `/:id(\\d+)`, and lookaheads such as `/((?!uk/).*)`. A rule can also require (`has`) or exclude (`missing`) a header, cookie, host or query parameter:

```json
{
  "redirects": [
    {
      "source": "/:path((?!beta/).*)",
      "has": [{ "type": "cookie", "key": "beta", "value": "true" }],
      "destination": "/beta/:path",
      "permanent": false
    }
  ]
}
```

### Redirects

- A redirect answers 308 by default. `"permanent": false` makes it 307, and `statusCode` can be 301, 302, 303, 307 or 308.
- The visitor’s query string is kept, with the destination’s parameters set over it: `/old?x=1` redirected to `/new?from=old` lands on `/new?x=1&from=old`.

### Rewrites

- A rewrite to one of the deployment’s files serves that file. A single-page app built with Vite needs one: `{ "source": "/(.*)", "destination": "/index.html" }`.
- A rewrite to a function (`/api/main.py`) runs it with the path the visitor asked for.
- A rewrite to an `https://` URL is proxied. The other site has 120 seconds to start answering, or the visitor gets 504 `ROUTER_EXTERNAL_TARGET_ERROR`.

### Headers

Headers apply to whatever answers: a file, a function, an external site or the 404 page. A header your function sets itself wins over the same header from `vercel.json`.

### Transforms and mitigations

A route in `routes` can change the request and the answer with Vercel’s `transforms` (`request.headers`, `request.query`, `request.path`, `response.headers`, each with `set`, `append` or `delete`), or answer with the firewall’s deny or challenge using `"mitigate": { "action": "deny" }`.

```json
{
  "routes": [{
    "src": "/home",
    "continue": true,
    "transforms": [
      { "type": "request.query", "op": "set", "target": { "key": "theme" }, "args": "dark" },
      { "type": "response.headers", "op": "delete", "target": { "key": "x-powered-by" } }
    ]
  }]
}
```

> **Mistakes are caught before upload:** A pattern that doesn’t compile, a destination that uses a parameter its source doesn’t have, or `permanent` together with `statusCode` stops the deploy with a message, before anything is uploaded. The deploy prints how many rules it found, and each request’s log line names the rule that decided it, such as `redirects[3]`.

## Bulk redirects

For thousands of plain path-to-URL redirects, such as an old site’s pages, use bulk redirects: up to 1,000,000 a project, looked up in under a microsecond. Each has a `source` (a path, or a full URL to match one host), a `destination`, and optionally `permanent`, `statusCode`, `caseSensitive` and `preserveQueryParams`.

### With the deployment

Name a CSV, JSON or JSONL file (or a folder of up to 100 of them) in `vercel.json`. The file is read after the build and isn’t served.

**vercel.json**

```json
{ "bulkRedirectsPath": "redirects.csv" }
```

**redirects.csv**

```text
source,destination,permanent
/old-page,/new-page,true
https://old.example.com/blog,/blog,true
```

### Per project, without a redeploy

Keep them on the project instead, under **Routing → Bulk redirects** or with `forkrail redirects`. Changes are staged as a new version and route nothing until you publish; publishing reaches every router within seconds, and older versions can be restored.

```bash
forkrail redirects add my-site /old /new --permanent
forkrail redirects import my-site redirects.csv    # adds to the current ones; --replace for all
forkrail redirects test my-site https://my-site.example.com/old
forkrail redirects publish my-site                 # or: discard, versions, restore VERSION, export
```

An import through the dashboard or a signed-in CLI is at most 5 MB (about 50,000 redirects). With the install’s AWS credentials (`--aws`) it can be any size.

## Routing rules

Routing rules are the project’s own rewrites, redirects and header changes, kept outside any deployment, so they apply to every deployment at once and change without a redeploy. Each matches a path (exactly, by a pattern like `/blog/:slug`, or by a regex), optionally a host, header, cookie or query, and then:

- rewrites to a path or URL, redirects (301, 302, 303, 307 or 308) or answers with a status;
- sets, appends or deletes response headers, request headers and query parameters.

The first rule with a rewrite, redirect or status decides; the header changes of every rule that matches apply. Edit them under **Routing → Routing rules**, or:

```bash
forkrail routes add my-site "API proxy" --src '/api/:path*' --src-syntax path-to-regexp \
  --action rewrite --dest 'https://api.example.com/:path*'
forkrail routes add my-site "Old blog" --src /blog --src-syntax equals \
  --action redirect --dest /articles --status 301
forkrail routes add my-site "Login" --src '/account/:path*' --src-syntax path-to-regexp \
  --action redirect --dest /login --missing cookie:session
forkrail routes add my-site "CORS" --src '^/api/.*$' --set-response-header 'access-control-allow-origin=*'
forkrail routes test my-site /account/x -H 'cookie: session=1'
forkrail routes publish my-site
```

Like bulk redirects, every change is staged until you publish, with history and restore. Anyone in the team can look and test; members and owners can change them.

## Limits

| What | Limit |
| --- | --- |
| Items in each `vercel.json` routing key | 2,048 (Vercel’s) |
| Length of a source or destination | 4,096 characters |
| Conditions in one `has` or `missing` | 16 |
| Bulk redirects per project | 1,000,000 |
| Bulk redirect import through a sign-in | 5 MB |
| External rewrite starts answering | 120 seconds |

Cost: routing runs in the routers you already pay for. 2,048 rules add about 7 microseconds to a request.

---

# Routing Middleware

> Run a function before routing to answer, rewrite or redirect a request, or change its headers, with the same `middleware.ts` you use on Vercel.

- Category: Routing and caching
- URL: https://www.forkrail.com/docs/middleware

## Add middleware

Put a `middleware.ts` or `middleware.js` at the project’s root. Its `config.matcher` says which paths it runs on; without one it runs on every path.

**middleware.ts**

```ts
import { next, rewrite, geolocation } from '@vercel/functions'

export const config = { matcher: ['/shop/:path*'] }

export default function middleware(request: Request) {
  const { country } = geolocation(request)
  if (country === 'DE') return rewrite(new URL('/de' + new URL(request.url).pathname, request.url))
  return next({ headers: { 'x-from-middleware': '1' } })
}
```

The middleware can answer the request itself, let it go on (`next()`), rewrite it to another path or URL (`rewrite()`), change its request headers, and add headers and cookies to the answer. `ipAddress()` and `waitUntil()` from `@vercel/functions` work too.

Two other ways to add it: `vercel.json`’s `proxy` key (`{ "entrypoint": "proxy.ts", "matcher": ["/api/:path*"] }`), or a framework’s own middleware (Astro’s `edgeMiddleware`, Nitro’s `vercel-edge`, or any Build Output route with `middlewarePath`).

## How it runs

- It’s bundled with esbuild, npm packages included, and runs on Node in the deployment’s own Lambda function. Middleware written for the Edge runtime (`config.runtime: "edge"`) runs on Node too, as Vercel now runs middleware by default.
- It runs after `vercel.json`’s redirects and headers, and before the files, rewrites and functions.
- It must start answering within its own max duration, or 25 seconds, or the request gets 504 `MIDDLEWARE_INVOCATION_TIMEOUT`.
- A request body over 4.5 MB on its paths gets 413 `FUNCTION_PAYLOAD_TOO_LARGE`, as on Vercel.
- Each call is in the request’s log line: what the middleware did, and how long it took. **Observability → Middleware** charts it.

## Cost

Each request the matcher lets in is a call on the deployment’s Lambda worker, billed as Lambda time like any function request. Paths outside the matcher don’t run it and cost nothing extra. Keep the matcher narrow so static files skip it.

## Not supported yet

- Middleware beside a Python API or a single Node server (Express, Nitro’s `node-server`): the deploy refuses it for now. It works beside static sites, Node functions in `api/`, and framework builds.
- Middleware written in Python, and `vercel.json`’s `skipMiddlewareRequestBody`.
- A root `middleware.ts` in a Next.js project: Next.js brings its own, as on Vercel.

---

# Caching and ISR

> Serve pages and API answers again without running your function: Incremental Static Regeneration, `s-maxage` caching, and purging by tag.

- Category: Routing and caching
- URL: https://www.forkrail.com/docs/caching

## What gets cached

The routers keep two kinds of answers and serve them again without running your function, as Vercel does. Every answer says how it was served in its `x-vercel-cache` header.

| x-vercel-cache | Meaning |
| --- | --- |
| `HIT` | Served from the cache. |
| `STALE` | Served from the cache while it’s made again in the background. |
| `MISS` | Not in the cache: the function ran. |
| `PRERENDER` | The build’s fallback page, until the page is made. |
| `REVALIDATED` | Made again on request, then served. |
| `BYPASS` | Draft Mode: the function ran and nothing was kept. |

## Pages (ISR)

Pages your framework marks for Incremental Static Regeneration (SvelteKit’s `config.isr`, Astro’s `isr`, Nitro’s `isr` route rules, Next.js’s `revalidate`) are kept until they expire, then served once more as `STALE` while the function makes them again, one at a time.

**src/routes/blog/[slug]/+page.server.ts (SvelteKit)**

```ts
export const config = {
  isr: { expiration: 60 }, // seconds
}
```

- A regeneration that fails leaves the page as it was, and is tried again after 30 seconds.
- Pages are made without the visitor’s cookies and `Authorization`, since they’re kept for everyone. Draft Mode still gets them.
- Each router keeps pages on its own disk (up to 2 GB) and the most used in memory. A page unused for 31 days is dropped.
- To make a page again now, send a GET with `x-prerender-revalidate: <the prerender’s bypass token>`.

## API and function answers

Any function can ask for its answer to be cached with `s-maxage`, as on Vercel’s CDN. The first of `Vercel-CDN-Cache-Control`, `CDN-Cache-Control` and `Cache-Control` that has one is used.

**api/prices.ts**

```ts
export async function GET() {
  return Response.json(await loadPrices(), {
    headers: { 'Cache-Control': 's-maxage=60, stale-while-revalidate=300' },
  })
}
```

That answer is kept for 60 seconds in each router’s memory, then served stale for up to 5 more minutes while one request refreshes it. Visitors get it without the `s-maxage` part.

**What can be cached:** GET and HEAD requests without `Authorization`, with status 200, 301, 302, 307, 308, 404 or 410, up to 10 MB, and without `set-cookie`, `private`, `no-cache`, `no-store` or `Vary: *`/`Vary: Cookie`. The key is the host, deployment, path and query, plus `Accept`, `Accept-Encoding` and any headers `Vary` names. POST answers are never cached.

An answer that sets no caching gets `cache-control: public, max-age=0, must-revalidate`, as on Vercel.

## Purge by tag

Tag what’s cached with a `Vercel-Cache-Tag` header (comma-separated; visitors never see it) or `addCacheTag()` from `@vercel/functions`, then purge by tag:

- **Invalidate**: tagged answers are served once more as `STALE` while they’re made again. This is the safe default.
- **Delete**: tagged answers are made again while the next visitor waits. Many paths at once can flood your functions, so prefer invalidate.
- `*` purges everything the project’s deployments cached.

**From your app**

```ts
import { invalidateByTag, dangerouslyDeleteByTag } from '@vercel/functions'

await invalidateByTag(['products', 'product-123'])
await dangerouslyDeleteByTag(['products'], { revalidationDeadlineSeconds: 3600 })
```

**From the CLI**

```bash
forkrail cache invalidate -p my-site --tag products,product-123   # --target production|preview
forkrail cache dangerously-delete -p my-site --tag products --revalidation-deadline-seconds 3600
forkrail cache purge -p my-site     # invalidate everything
forkrail cache ls my-site           # the latest purges
```

A purge from your app reaches every router in about half a round trip between regions; one from the CLI or dashboard (**Settings → Caches**) within a second. Tags are case-sensitive, up to 256 bytes each and 128 per answer.

## Cost

Caching has no fixed cost and stores nothing in S3: it lives on the routers’ own memory and disks. Every cached answer is a function run you don’t pay for, and a regeneration is one function request. **Observability → Cache** shows your hit rate.

---

# Image Optimization

> Resize and convert images on request, with the same `images` settings and `/_vercel/image` URLs as Vercel. Next.js’s `<Image>` works as it is.

- Category: Routing and caching
- URL: https://www.forkrail.com/docs/image-optimization

## Turn it on

Add `images` to `vercel.json`, in Vercel’s shape. The deployment then answers `/_vercel/image?url=…&w=…&q=…` (and `/_next/image` for Next.js).

**vercel.json**

```json
{
  "images": {
    "sizes": [640, 1080, 1920],
    "formats": ["image/avif", "image/webp"],
    "minimumCacheTTL": 60,
    "remotePatterns": [{ "protocol": "https", "hostname": "^images\\.example\\.com$" }]
  }
}
```

Frameworks that bring their own settings work the same way: Next.js’s `images` config, SvelteKit’s adapter `images` option, Astro’s `imageService` and Nuxt Image’s Vercel provider. If `vercel.json` has `images` too, the framework’s are used and the build warns.

## How it works

- `url` is one of the deployment’s own paths, or a URL elsewhere that `domains` or `remotePatterns` allows.
- The image is resized to width `w` (never enlarged) and sent in the first of `formats` the browser accepts.
- JPEG, PNG, WebP and AVIF are resized. GIF, SVG (with `dangerouslyAllowSVG`), icons and animations are served as they are.
- Each resized image is kept once for the whole install, so a resize made through one region is there for every other. The deployment’s own files are kept by content across redeploys; others follow the longer of their `max-age` and `minimumCacheTTL`.
- Images from a function get none of the visitor’s headers (cookies, `Authorization`), since the result is kept for everyone. Keep private images at their own URLs.

## Limits and cost

| What | Limit |
| --- | --- |
| Largest source image | 8,192 pixels a side, as on Vercel |
| Image a function answers | Read up to 4 MB |
| Image from another site | Read up to 50 MB (Vercel reads up to 300 MB), public addresses only, at most 3 redirects |
| Resized images kept | 31 days from when they’re made |

Cost: nothing while unused, then about **$0.011 per 1,000 WebP resizes** (Lambda time and one S3 write), a little more for AVIF, and $0.0004 per 1,000 reads from S3 when a router’s memory doesn’t have the image.

---

# Skew protection

> A page loaded before a deploy keeps talking to the deployment that served it, so its scripts, data requests and server actions don’t break.

- Category: Routing and caching
- URL: https://www.forkrail.com/docs/skew-protection

## What it does

When you deploy while someone has your site open, their page still has the old deployment’s script names and data shapes. With skew protection, every request that names a deployment (`?dpl=<id>`, the `x-deployment-id` header or the `__vdpl` cookie) is served by that deployment while it’s younger than the maximum age (12 hours by default) and still kept.

Your framework does the naming. SvelteKit, Nuxt, TanStack Start, Qwik and React Router set the cookie; Next.js 14.1.4 and later and Astro put the id on their requests. Remix does neither, on Vercel either.

## Turn it on or off

It’s on by default for new projects, from their first successful build, and costs nothing. Change it under **Settings → Advanced → Skew Protection**, or:

```bash
forkrail project my-site --skew-protection on        # or off; applies at once
forkrail project my-site --skew-max-age 7d           # 30m, 12h, 7d...; 'default' is 12 hours
forkrail project my-site --skew-threshold a1b2c3d4   # this deployment and older are never pinned again
forkrail project my-site --skew-allowed-domains app.example.com   # other sites whose pages may pin
```

Use a threshold after a deploy that fixes a security problem: no open page can reach the older deployments again.

## What’s never pinned

- A page load or refresh: those always get the newest deployment.
- A request from another site, unless it’s one of the allowed domains (up to 12).
- A deployment older than the maximum age, older than the threshold, deleted, or from another project.
- A preview on a production address, so production names never serve preview code.

Search crawlers from Google and Bing (checked by their published addresses) can reach deployments up to 60 days old, so pages they indexed keep loading. The request log’s `skew` field says what happened to each request that named a deployment.

---

# Logs and observability

> Every request, its function run, your app’s output and its outgoing calls, kept in your own account and searchable from the dashboard or the CLI.

- Category: Monitor
- URL: https://www.forkrail.com/docs/logs-and-observability

## What’s kept

The routers log every request and send it to the analytics store, a ClickHouse server in your own AWS account. Nothing goes to a third party.

| What | Details |
| --- | --- |
| Requests | Host, deployment, method, path, query, status, timings (queued, first byte, total), bytes, client IP, user agent, location, and the rule that routed it. Query parameters named like `key`, `token` or `secret` are masked. |
| Function runs | Environment, runtime, memory used against the memory size, duration against max duration, the route template (`/items/{item_id}`), and how it started: `warm`, `thaw` or `cold`. |
| Your app’s output | stdout and stderr, tagged with the request they belong to. |
| Outgoing requests | Each HTTP call your app makes while serving a request: host, path, status, duration and size. Timed for Python (requests, httpx, aiohttp, urllib, curl_cffi) and Node (fetch, `node:http`) without changing your code. |
| Problems | Retries, crashes, timeouts, cut-off responses and upstream failures. |
| A copy in S3 | Every 10 minutes, as JSON lines, in the install’s artifacts bucket under `logs/router/`. |

Every response has an `x-forkrail-request-id` header. Ask a user for it and you can find their exact request.

### App output limits

Each request keeps up to 256 lines and 1 MB of output, and a line can be 256 KB, as on Vercel. There’s no limit per second, so a busy deployment keeps every request’s output. Output past a request’s limits, and lines printed outside any request (start-up, background threads), share 128 KB a second per deployment. What isn’t kept is counted, and the request panel says how much is missing.

## In the dashboard

- **Logs** (team or project): requests by default; switch to **All traffic** to include server functions and app output. Filter by status, type, method, domain, deployment, path or text, and open a request to see its timeline, function run, outgoing calls and output.
- **Observability**: charts for requests, functions (duration, memory, cold starts), middleware, cache hits and external APIs, over any time range.
- **Usage**: requests, function time, transfer and cost per project, from the routers’ count and from AWS’s bill.

## From the CLI

```bash
forkrail logs my-api                              # the last hour's requests, newest last
forkrail logs my-api --status 5xx --since 1d
forkrail logs my-api --path /search -f            # follow: new requests every 2 seconds
forkrail logs my-api --request 1f3a9c0d2e4b5a6c   # one request in full, with its output
forkrail logs my-api --app --level error --since 6h   # your app's output; --search TEXT
forkrail stats my-api --since 7d                  # status, latency, cold starts, busiest paths
forkrail usage --since 30d                        # requests, GB-seconds, transfer and cost per project
forkrail usage my-api --daily
```

| Option | Does | Default |
| --- | --- | --- |
| `--since`, `--until` | Time range: `30s`, `15m`, `2h`, `7d` or a UTC time | Last hour (`stats`: 24 hours, `usage`: 30 days) |
| `--status` | A class (`5xx`) or a code (`404`) | All |
| `--path`, `--host` | Paths starting with, or one hostname | All |
| `-n`, `--limit` | The newest N rows | 100 |
| `-f`, `--follow` | Keep printing new rows | Off |
| `--app`, `--level`, `--search` | Your app’s output, by level or text | Requests |

## Location headers your app gets

The router looks up each visitor’s location and passes it on as Vercel does: `x-vercel-ip-country`, `x-vercel-ip-continent`, `x-vercel-ip-city`, `x-vercel-ip-latitude` and `x-vercel-ip-longitude`, plus `x-real-ip` and `x-forwarded-for`. Any the client sent are removed first.

Locations come from DB-IP’s free databases (CC BY 4.0), refreshed monthly. They have no region codes, time zones or postal codes, so `x-vercel-ip-country-region`, `-timezone` and `-postal-code` aren’t sent.

## Cost

Logs are part of the install’s fixed cost: the analytics server (about $0.90 a day with its 50 GB disk) and the S3 copy. Request logs, function runs and app output have no expiry set, and the S3 copy is kept too. There’s no per-GB log charge and no log drain to pay for.

---

# Web Analytics

> Visitors, page views, bounce rate, pages, referrers, countries, devices and custom events per project, without cookies, kept in your own account. Apps using `@vercel/analytics` need no change.

- Category: Monitor
- URL: https://www.forkrail.com/docs/web-analytics

## Turn it on

1. **Switch it on for the project**

   Open the project’s **Analytics** page and choose **Enable**, or use the CLI. It applies within seconds, with no redeploy.

```bash
forkrail project my-site --analytics on      # off stops collecting; what was kept stays
```

2. **Add the script to your pages**

   Add the script tag to your HTML, or keep `@vercel/analytics` if your app already uses it. Then deploy.

```text
<script defer src="/_forkrail/insights/script.js"></script>
```

3. **Open a page**

   Visit your site. The Analytics page shows the view within a few seconds, and who’s online now (visitors in the last 3 minutes).

### Apps that use @vercel/analytics

An app that already has `<Analytics />` from `@vercel/analytics` works as it is: the routers answer its script and beacons themselves, and nothing is sent to Vercel. Custom events with `track()` work too, in the browser and on the server.

```ts
import { track } from '@vercel/analytics'

track('signup', { plan: 'pro' })
```

While analytics is off, the script is an empty one, so you can ship the tag before you turn it on. forkrail’s own package, `@forkrail/analytics`, is in the forkrail source (`packages/analytics`) and isn’t on npm yet; until it is, use the script tag or `@vercel/analytics`.

## Privacy

- **No cookies.** A visitor is a hash of their address, browser and the project under a random salt that changes every UTC day. The same person counts as a new visitor the next day, and neither the address nor the browser string is kept.
- Bots, headless browsers and scripts aren’t counted, nor are beacons from another project’s pages.
- Everything is kept on the analytics server in your AWS account for 13 months.

Because no cookie or personal data is stored on the visitor’s device, many sites can run it without a consent banner. Check what your own rules require.

## Cost and differences from Vercel

Analytics adds no AWS resources: page views go through the routers and into the analytics server you already run. Each beacon counts as a request in the project’s usage, a few hundred bytes of transfer.

|  | forkrail | Vercel |
| --- | --- | --- |
| Price | No charge beyond the beacons’ transfer | Per event, by plan |
| Where data lives | Your AWS account | Vercel |
| Kept | 13 months | By plan |
| Speed Insights | Not collected: its script loads and does nothing | Collected |

---

# Spend limits and budgets

> forkrail counts what each project costs as it’s spent and pauses a project the moment it reaches its budget, so a bug, a loop or a flood can’t run up your AWS bill.

- Category: Monitor
- URL: https://www.forkrail.com/docs/spend-budgets

## Set a budget

Budgets are monthly, in dollars, for the calendar month in UTC. Every install has a team budget, which starts at **$20**; a project can also have its own, which counts toward both. Set them under team **Settings → Spend Management**, or:

```bash
forkrail spend show                          # the budgets, and what's paused
forkrail spend budget 200                    # the team budget: $200 a month
forkrail spend budget 50 --project my-api    # my-api's own budget
forkrail spend no-budget my-api              # only the team budget applies to it again
forkrail spend exempt my-dashboard           # keeps running when the team budget is reached
```

While nobody has set the team budget, a month that ends at 90% or more of it raises the next month’s a step, so a growing site isn’t paused by the starting value.

## What’s counted

Spend is counted at AWS’s list price, in the units AWS bills, every few seconds. Free tier allowances aren’t taken off, since they belong to the whole account, so the figure errs high.

- Function time at the function’s memory, start-up included, and each invocation.
- Bytes to and from visitors, as the router counted them on the wire.
- Bytes between the routers and your functions, and between regions.
- What your functions send to the internet themselves.
- Builds, image resizes, warm-ups and S3 requests.

Fixed costs (the router, the analytics server, keys) aren’t in a budget: they’re known in advance and the same every month. Services your app calls with its own IAM role (a database, queues) aren’t seen either; the Usage page shows them from AWS’s bill.

## What happens at a budget

Within about a second of reaching a budget (ten for spend in another region):

- Every host of the project answers `503 DEPLOYMENT_PAUSED`: no function runs and no file is served. At the team budget, that’s every project except those kept running with `spend exempt`.
- Work in flight is stopped, and Lambda is told to refuse the project’s function (its reserved concurrency is set to 0).
- No build of it starts.

Owners hear at 50%, 75% and 100% of each budget, then at each further 100%, and when a project spends more than 10% of its monthly budget in an hour. Each alert names what spent most: the kind of cost, the path and the client’s network. Alerts go to the dashboard’s bell, email if set up, and [webhooks](https://www.forkrail.com/docs/notifications).

> **A second line of defence:** A separate guard reads AWS’s own numbers every 5 minutes and pauses a project if the routers somehow didn’t. The installer also creates an AWS Budget of $150 a month that emails you, as a backstop for anything outside forkrail.

## Resume a project

A paused project stays paused until someone resumes it, even when a new month starts. Raise the budget first: a project still at or over its budget is paused again within a second.

```bash
forkrail spend resume                  # every paused project
forkrail spend resume my-api           # just my-api
forkrail spend resume --keep shop      # all but shop (say, the one under attack)
forkrail spend pause my-api            # pause by hand
```

Owners change budgets and pause or resume; everyone in the team can see them.

## Differences from Vercel

On Vercel, Spend Management is a Pro plan setting that can pause production deployments when you reach an amount. On forkrail every install has a budget from the start, counted every few seconds; it pauses previews and production alike and stops work already in flight. It covers what your AWS resources cost, since there is no plan and no included usage.

---

# Webhooks, email and notifications

> Get told when a deployment fails, a budget is reached or an attack starts: in the dashboard’s bell, by email through your own provider, or as signed webhooks.

- Category: Monitor
- URL: https://www.forkrail.com/docs/notifications

## Events

| Event | When |
| --- | --- |
| `deployment.created` | A deployment starts. |
| `deployment.succeeded` | A deployment is ready. |
| `deployment.error` | A deployment failed. |
| `deployment.canceled` | A deployment was canceled. |
| `deployment.promoted` | Production moved to a deployment. |
| `deployment.rollback` | Production rolled back to a deployment. |
| `budget.reached` | Spend reached 50, 75 or 100% of a budget. |
| `budget.raised` | The default team budget grew for next month. |
| `spend.paused` | A project was paused at its budget. |
| `spend.fast` | A project spent over 10% of its monthly budget in an hour. |
| `attack.detected` | The system mitigations are refusing an attack. |
| `domain.certificate.renew.failed` | A custom domain’s certificate failed to renew. |

## Webhooks

1. **Add a webhook**

   Team **Settings → Webhooks** (owners): an HTTPS URL, the events it wants, and all projects or chosen ones. Up to 20 per install.

2. **Keep the secret**

   It’s shown once, when the webhook is made. Use it to check signatures.

3. **Send a test**

   **Send test event** posts a `webhook.test` so you can check your endpoint.

Each event is one POST with Vercel’s body shape: `{ "id", "type", "createdAt", "payload", "region" }`, where `payload` has the deployment, its links, its target and the project. Check the `x-forkrail-signature` header, the hex HMAC-SHA1 of the raw body with your secret:

**api/forkrail-webhook.ts**

```ts
import crypto from 'node:crypto'

export async function POST(request: Request) {
  const body = await request.text()
  const expected = crypto.createHmac('sha1', process.env.WEBHOOK_SECRET!).update(body).digest('hex')
  const given = request.headers.get('x-forkrail-signature') ?? ''
  if (given.length !== expected.length || !crypto.timingSafeEqual(Buffer.from(given), Buffer.from(expected))) {
    return new Response('bad signature', { status: 401 })
  }
  const event = JSON.parse(body)
  console.log(event.type, event.payload.deployment?.url)
  return new Response('ok')
}
```

- An answer other than 2xx within 30 seconds is retried after 1, 5 and 15 minutes, then 1, 2, 4, 8 and 12 hours, for up to a day. Each try is listed with the webhook for 30 days.
- `x-forkrail-event` names the event and `x-forkrail-delivery` the try.
- Webhooks reach public addresses only, and redirects aren’t followed.

## Email

Email is off until an owner sets it up under team **Settings → Email**. It goes through your own provider; forkrail sends nothing itself.

| Provider | Setup |
| --- | --- |
| Amazon SES | In your install’s account. The dashboard can add the From domain and lists its three DKIM records for your DNS. A new AWS account starts in SES’s sandbox (mail reaches only verified addresses) until you request production access in the SES console. |
| SMTP | Any other provider (Resend, Postmark, SendGrid, Mailgun, Google Workspace, your own server): host, port 587 (STARTTLS) or 465 (TLS), user name and password. Port 25 is blocked by Lambda. |

**Send test email** shows what the provider answered. SES costs $0.10 per 1,000 emails.

## The bell, and who hears what

- A **failed deployment** goes to whoever made it, if they’re a member (the GitHub user who pushed or who pressed the button), else to the owners.
- A **certificate renewal failure**, an **attack** and **budget alerts** go to the owners.
- Each person chooses, under **My notifications**, which kinds reach their bell and their email, and confirms their email address there.
- Notifications are kept for a year.

---

# Firewall

> Block, challenge, redirect or rate-limit requests before they reach your app, with custom rules, IP blocks, attack mode and always-on DDoS mitigations. Changes apply in about a second, without a redeploy.

- Category: Security and team
- URL: https://www.forkrail.com/docs/firewall

## How it works

Every project has a firewall in front of all its deployments and domains, and the install has one in front of every project. It runs in the routers before anything else: before deployment protection, redirects, files and functions.

1. **System mitigations**, always on, refuse floods from a single address.
2. The **install’s firewall**, which owners manage, runs for every project.
3. **Attack mode**, when it’s on, challenges every visitor.
4. The project’s **IP blocks**, then its **custom rules**, in order.

Every change is a draft until you publish it. Publishing reaches every router within about a second, every version is kept, and any version can be made live again. The project’s **Firewall** page has tabs for Overview, Traffic, Blocked, DDoS and Rule Settings.

## Custom rules

A rule matches requests by conditions, then takes an action. From the CLI, a condition is `[not] TYPE[:KEY] OP VALUE`; join them with `--and` (all must match) or `--or` (either group).

```bash
forkrail firewall rule add my-api --name "Block .env probes" --if 'path suf .env' --then deny --for 1h
forkrail firewall rule add my-api --name "Admin from outside the US" \
  --if 'path pre /admin' --and 'not country eq US' --then deny
forkrail firewall rule add my-api --name "Old page" --if 'path eq /old' --then redirect --location /new --permanent
forkrail firewall rule add my-api --name "Scrapers" --if 'ua sub python-requests' --or 'asn inc 14061,16276' --then log
forkrail firewall rule add my-app --name "Login page" --if 'path eq /login' --then challenge
forkrail firewall diff my-api       # what publishing would change
forkrail firewall publish my-api    # or: discard, versions, rollback VERSION
```

### What a rule can match

| Type | Matches |
| --- | --- |
| `path`, `raw_path`, `target_path` | The decoded path, the path as sent, or the file a request is served from. |
| `method`, `host`, `protocol`, `scheme` | The request line and host. |
| `header:NAME`, `query:NAME`, `cookie:NAME` | A header, query parameter or cookie by name. |
| `user_agent` (or `ua`) | The client’s user agent. |
| `ip_address` (or `ip`) | An address or CIDR range. |
| `geo_country` (`country`), `geo_continent`, `geo_country_region`, `geo_city` | Where the client is. |
| `geo_as_number` (`asn`) | The client’s network, such as a hosting provider. |
| `ja4_digest` (`ja4`) | The TLS client’s JA4 fingerprint: browsers, script libraries and scanners each have their own, whatever user agent they claim. |
| `environment` (`env`) | `production` or `preview`. |
| `region` | The router’s AWS region. |

Operators: `eq`, `neq`, `pre` (starts with), `suf` (ends with), `sub` (contains), `re` (regex), `inc` and `ninc` (is or isn’t one of up to 75 values), `ex` and `nex` (exists or not), `gt`, `gte`, `lt`, `lte`, and `list` (in a named IP list). Every comparison ignores case.

### Actions

| Action | What the visitor gets |
| --- | --- |
| `deny` | 403, with `x-forkrail-mitigated: deny`. |
| `challenge` | A page that runs a moment of JavaScript, then reloads with a pass good for an hour. For browsers only: API clients and `curl` stay at the page. |
| `redirect` | 307, or 301 with `--permanent`, to `--location`. |
| `rate_limit` | See [rate limits](#rate-limits). |
| `bypass` | Skips the remaining rules. |
| `log` | Nothing: the request is recorded and goes on. |

A deny or challenge can also hold the client’s address for 1 minute to 1 hour (`--for 15m`), so every request it sends gets the same answer until then.

## Rate limits

A rate limit allows a number of requests per window for each client, and answers the rest with 429 (`retry-after` included), 403 or just a log line.

```bash
# 10 login attempts a minute per IP; over that, denied for 15 minutes
forkrail firewall rule add my-api --name "Login" --if 'path eq /api/login' \
  --then rate_limit --requests 10 --window 60 --over deny --for 15m

# 1,000 requests a minute per API key, with bursts
forkrail firewall rule add my-api --name "API keys" --if 'path pre /api' \
  --then rate_limit --requests 1000 --window 60 --key header:x-api-key --algo token_bucket
```

- `--window`: 10 to 3,600 seconds (default 60). `--requests`: 1 to 10,000,000.
- `--key`: what a client is: `ip` (an IPv6 address counts by its /64), `ja4`, `header:NAME`, `user_agent`, `asn`, `cookie:NAME`, `query:NAME`, `path`, `host` or `country`. Several keys count each combination apart.
- `--algo`: `fixed_window` (windows start on the clock) or `token_bucket` (bursts up to the limit, then refills).
- Counts are each router’s own, as Vercel’s are each region’s.

### Rate limits from your own code

Your app can ask the firewall about its own keys, such as a user id. `checkRateLimit` from `@vercel/firewall` works unchanged: make a rule with a `rate_limit_api_id` condition, and call it with the request.

```bash
forkrail firewall rule add my-api --name "Updates per user" --if 'rate_limit_api_id eq update-object' \
  --then rate_limit --requests 20 --window 60
```

```ts
import { checkRateLimit } from '@vercel/firewall'

export async function POST(request: Request) {
  const { rateLimited } = await checkRateLimit('update-object', { request, rateLimitKey: userId })
  if (rateLimited) return new Response('Too many requests', { status: 429 })
  // ...
}
```

## IP blocks

IP blocks run before the custom rules: an address or range, on one host, every subdomain (`*.example.com`) or every host of the project, with `deny`, `log` or `bypass`.

```bash
forkrail firewall ip add my-api 192.0.2.0/24 --host api.example.com --note "abuse report 42"
forkrail firewall show my-api    # rules, IP blocks and their ids
```

## Attack mode

Under attack, turn on attack mode from the Firewall page’s button or the CLI. It challenges every visitor to the project for 1, 6 or 24 hours, and applies at once.

```bash
forkrail firewall attack-mode my-app --for 6h    # --off to stop
```

Cron jobs, verified crawlers (Google, Bing, Apple, DuckDuckGo and OpenAI, checked by their published addresses), Stripe’s and GitHub’s webhooks, and your system bypasses pass without a challenge.

## DDoS mitigations

Always on, in front of every project, at no cost:

- An address may hold at most 256 connections open.
- An address that sends more than 5,000 requests in 10 seconds is blocked for 10 minutes. Its new connections are closed before the TLS handshake.

A **system bypass** leaves an address you trust alone, such as a partner’s servers (up to 100). Owners can change the limits for the whole install, or pause the mitigations for 24 hours.

```bash
forkrail firewall system-bypass add my-api 203.0.113.0/24 --note "partner's servers"
forkrail firewall limits --connections 1024 --requests 20000 --block 5m   # owners; --reset for the defaults
forkrail firewall mitigations my-api
```

## Test, import and limits

Test what the firewall would do with a request before you publish:

```bash
forkrail firewall test my-api https://api.example.com/admin --ip 192.0.2.7 --country DE
forkrail firewall import my-api vercel-firewall.json    # a configuration exported from Vercel
```

| What | forkrail |
| --- | --- |
| Rules per configuration | 1,000, of which 100 can be rate limits |
| Values in one `inc` condition | 75 |
| System bypasses | 100 |
| Time to apply a change | About a second, on every router |
| Price | Included. Rate limiting, challenges and attack mode cost nothing extra. |

Anyone in the team can look and test. Members and owners change a project’s firewall; owners change the install’s (`--install`). Each request’s log line records what the firewall did and which rule decided.

---

# Deployment protection

> Keep previews, or every deployment, private: require a team sign-in, a password or a trusted IP, and let automation in with bypass secrets.

- Category: Security and team
- URL: https://www.forkrail.com/docs/deployment-protection

## Choose what’s protected

| Scope | Protects |
| --- | --- |
| `standard` | Every generated URL: deployment and branch URLs. Production names (your domains and `<project>.<your-domain>`) stay open. |
| `all` | Every URL, production included. |
| `off` | Nothing. |

Set it under the project’s **Settings → Deployment Protection**, or from the CLI. Owners can set the default for every project that has no setting of its own. A fresh install starts with protection off.

```bash
forkrail protection show my-app
forkrail protection set my-app --scope standard --members on
forkrail protection default standard     # owners: every project without its own setting
```

Visitors without access are sent to sign in, if they’re in a browser; other clients get 401.

## Ways in

| Method | For | Set up |
| --- | --- | --- |
| Team sign-in | Members of your team, signed in with GitHub. | `--members on`, or **forkrail Authentication** in settings. |
| Password | Anyone you give it to, without an account. | **Password Protection** in settings. Only its hash is kept. |
| Trusted IPs | Only these addresses may open it, signed in or not. Anyone else gets 404. | `--trusted-ips 203.0.113.0/24` and `--trusted-scope standard|all|production`. |
| Share links | Anyone holding the link. | **Share** on a deployment’s page; take links back under **Shareable Links**. |
| Bypass secrets | Tests, monitors and scripts. | `forkrail protection bypass add`. |
| Exceptions | Hosts that stay public, such as a branch URL for a client. | `--exceptions staging.example.com`. |
| OPTIONS allowlist | CORS preflights on paths you name. | `--options-paths /api`. |

> **Sign everyone out:** `forkrail protection set my-app --sign-out` (or **Sign everyone out** in settings) ends every access given so far: team sign-ins and the password’s and share links’ cookies. Bypass secrets keep working.

## Automation and testing

Make a bypass secret for your end-to-end tests or uptime checks. It’s printed once; only its hash is kept.

```bash
forkrail protection bypass add my-app --env
# --env also makes it the project's FORKRAIL_AUTOMATION_BYPASS_SECRET (and VERCEL_AUTOMATION_BYPASS_SECRET)

curl -H "x-forkrail-protection-bypass: $SECRET" https://my-app-git-feature.example.com/
forkrail curl https://my-app-git-feature.example.com/ -- -i   # the CLI adds access for you
```

The header can also be a query parameter, and `x-vercel-protection-bypass` works too, so Playwright or Cypress setups written for Vercel keep working. Add `x-forkrail-set-bypass-cookie: true` to get a cookie for the rest of a browser session.

## Differences from Vercel

- Password protection, trusted IPs and share links are included. On Vercel, password protection and trusted IPs are paid extras.
- Team sign-in uses your install’s own GitHub App, so only people in your team can get in.
- The scopes match Vercel’s: `standard` is Vercel’s Standard Protection, `all` is All Deployments.

---

# Team, roles and sign-in

> Add people by GitHub username, give each a role, and let them deploy from their own terminal without AWS credentials.

- Category: Security and team
- URL: https://www.forkrail.com/docs/team-and-sign-in

## Add people

People sign in to the dashboard with GitHub, through a GitHub App that belongs to your install alone. There are no invitations or passwords: an owner adds a GitHub username under team **Settings → Members**, and that person opens the dashboard and chooses **Continue with GitHub**.

- The page shows whose account a username is before you add it.
- People are remembered by GitHub’s numeric id, so a renamed account is the same person and a freed username gives nobody access.
- A removed member is signed out everywhere within half a minute, terminals included.

## Roles

| Role | Can |
| --- | --- |
| Owner | Everything a member can, plus add or remove members, change roles, rename the team, manage budgets and email, and see Infrastructure. |
| Member | Deploy, promote, roll back, redeploy, cancel, change settings and env vars, connect repositories and make projects. |
| Developer | Deploy previews (from a terminal or by pushing), redeploy and cancel them, and change previews’ env vars. Nothing that touches production. |
| Viewer | See everything (deployments, logs, usage, env var names). Change nothing. |

A developer reaches production one way: a commit merged to the production branch. Who may merge is up to GitHub’s branch protection.

## Install owners

The install’s owners are kept outside the dashboard, and only someone with the AWS account can change them. They’re always owners, whatever the members list says, so this is also the way back in if you lock yourself out.

```bash
forkrail owners ls
forkrail owners add ada-lovelace     # can sign in as an owner within a minute
forkrail owners rm ada-lovelace      # the last one can't be removed
```

## Deploy without AWS credentials

Team members need no AWS account of their own, only the CLI and the dashboard’s address:

1. **Sign the terminal in**

   The CLI prints an address and a short code and opens the browser. Check the code matches and choose **Yes, sign it in**. On a machine without a browser, add `--no-browser` and open the address anywhere.

```bash
forkrail login https://dashboard.example.com
```

2. **Work as yourself**

   From then on the terminal acts as you, with your role.

```bash
forkrail deploy
forkrail deploy --prod
forkrail whoami
```

- Your source goes straight to S3, to an address signed for that one upload.
- The login lasts 90 days after its last use. **Account** in the dashboard’s user menu lists your terminals and signs any of them out; so does `forkrail logout`.
- A browser stays signed in for 30 days after its last use.
- Some commands still need the install’s AWS credentials: `stats`, `usage`, `limits`, `env migrate`, and building on your own machine (`--local`, `--prebuilt`).

### In CI

For a machine nobody sits at, set `FORKRAIL_TOKEN` (the token from a login) and `FORKRAIL_API` (the dashboard’s address) as environment variables instead of signing in. For most projects, [deploying from GitHub](https://www.forkrail.com/docs/deploy-from-github) needs no token at all.

**.github/workflows/deploy.yml**

```text
- run: curl -fsSL https://forkrail.com/install | sh
- run: forkrail deploy --prod
  env:
    FORKRAIL_TOKEN: ${{ secrets.FORKRAIL_TOKEN }}
    FORKRAIL_API: https://dashboard.example.com
```

## Where it’s kept

People, members, sessions and terminal logins are in a DynamoDB table in your account that only the dashboard and the administrators you name can read. Sessions and tokens are stored only as hashes, so a copy of the table signs nobody in. Every change to the team is kept in an audit trail, and the table can be restored to any second of the last 35 days.

---

# CLI reference

> Every `forkrail` command, grouped by what it’s for. Run `forkrail help COMMAND` for a command’s full options.

- Category: Reference
- URL: https://www.forkrail.com/docs/cli

## Install the CLI

**macOS and Linux**

```bash
curl -fsSL https://forkrail.com/install | sh
```

**Windows**

```bash
irm https://forkrail.com/install.ps1 | iex
```

Check it with `forkrail --version`. The CLI is one file with no dependencies, for macOS, Linux and Windows on x64 and Arm.

## Options every command takes

| Option | Does |
| --- | --- |
| `--profile NAME` | The AWS profile to use. Defaults to `AWS_PROFILE`, then the one `forkrail link` saved, then the AWS SDK’s default. |
| `--region REGION` | The install’s home region. Defaults to `FORKRAIL_HOME_REGION`, then the saved one, then `us-east-1`. |
| `--aws` | Use this machine’s AWS credentials even though the terminal is signed in. `FORKRAIL_AWS=1` does the same. |
| `-h`, `--help` | Show a command’s options. |
| `-V`, `--version` | Show the CLI’s version. |

A terminal works in one of two ways: **signed in** (`forkrail login`), acting as a team member with their role, or with the install’s **AWS credentials**, as its administrator. Signed-in commands go through the dashboard and need no AWS access.

## Deploy and manage deployments

| Command | Does |
| --- | --- |
| `forkrail [DIR]`, `forkrail deploy [DIR]` | Deploy a preview of the folder (the current one by default). `--prod` for production. With no command, forkrail deploys, as `vercel` does. |
| `forkrail ls [PROJECT]` | List projects, or a project’s deployments. |
| `forkrail inspect ID` | Show a deployment’s record. `--logs` for its build log. |
| `forkrail promote ID` | Make a deployment production. `--allow-preview-env` promotes a preview whose env vars differ from production’s. |
| `forkrail rollback [PROJECT]` | Point production back at the previous production deployment, or `--to ID`. |
| `forkrail redeploy ID` | Make a deployment again with today’s env vars and settings. `--prod`, `--skip-domain`, `--no-cache`. |
| `forkrail cancel ID` | Stop a build. |
| `forkrail rm ID` | Remove a deployment that isn’t production. `rm --project NAME` deletes a whole project. |
| `forkrail retention` | How long deployments are kept: `show`, `set`, `sweep`. |
| `forkrail restore ID` | Bring a deleted deployment back, within 30 days. |
| `forkrail build DIR --out OUT`, `forkrail publish OUT` | Build without publishing, then publish that build. |
| `forkrail curl URL -- ARGS` | curl a protected deployment as a team member. |

### deploy options

| Option | Does |
| --- | --- |
| `--prod` | Deploy to production. |
| `--project NAME` | The project. Defaults to the folder’s name. |
| `--memory MB` | Memory for this deployment only (128 to 10,240). |
| `--concurrent true|false` | Concurrent compute for this deployment only. |
| `--skip-domain` | With `--prod`: build production but leave your domains on the current deployment (a staged release). |
| `--no-cache` | Build without the build cache. |
| `--local` | Build on this machine instead of the install’s builder (needs AWS credentials). |
| `--prebuilt` | Deploy a framework’s existing build output. |

## Projects and functions

| Command | Does |
| --- | --- |
| `forkrail project NAME` | Show a project’s settings, or change them with the options below. |
| `forkrail limits NAME` | Show or set `--max-workers N` (1 to 1,000, or `default`). Applies within seconds. |
| `forkrail regions` | Router regions and where functions run: `ls`, `add`, `rm`, `setup`, `copy`. |
| `forkrail link` | Check the account has an install, and save the profile and region for later commands. |

### project options

| Option | Does |
| --- | --- |
| `--memory MB`, `--max-duration S` | Function memory and timeout. `default` clears one. |
| `--concurrent true|false` | Concurrent compute (alias `--fluid`). |
| `--max-inflight N` | Max requests per instance: how many requests share one worker, 2 to 50. Not a limit on the project: workers still scale out. |
| `--keep-warm N|auto` | Environments kept warm per region (0 to 20). |
| `--regions LIST` | Function regions, comma-separated. |
| `--role ROLE` | The IAM role functions run as, by name or ARN; `default` for the shared one. |
| `--framework NAME` | The framework preset. |
| `--auto-assign-domains on|off` | Whether production deploys move your domains (off for staged releases). |
| `--skew-protection on|off` | Skew protection, with `--skew-max-age`, `--skew-threshold`, `--skew-allowed-domains`. |
| `--analytics on|off` | Web Analytics. |
| `--rename NEW` | Rename the project. |

## Env vars, domains, schedules and hooks

| Command | Does |
| --- | --- |
| `forkrail env ls PROJECT`, `env add|rm PROJECT KEY` | List, add or remove env vars. `-e production|preview|development`, `--git-branch BRANCH`. Values come from stdin or a prompt, never the command line. |
| `forkrail env pull [FILE]` | Write Development’s variables to `.env.local` (or FILE). |
| `forkrail env run -- CMD` | Run a command with Development’s variables, writing no file: `forkrail env run -- next dev`. |
| `forkrail domains add DOMAIN PROJECT` | Add a custom domain. `--redirect OTHER --status 308`, or `--branch BRANCH` to follow a branch. |
| `forkrail domains ls|inspect|check|update|rm` | List, inspect, check DNS, change or remove domains. |
| `forkrail schedules ls|run|enable|disable|sync` | A project’s cron schedules (alias `crons`). |
| `forkrail deploy-hooks ls|create|rm` | Secret URLs that build a branch. `create --branch BRANCH`. |
| `forkrail git setup|status|repos|connect|disconnect|deploy` | The install’s GitHub App, and connecting a project to a repository. |

## Routing and cache

| Command | Does |
| --- | --- |
| `forkrail redirects ls|add|rm|import|export|test` | Bulk redirects. `add SRC DEST --permanent`, `import FILE --replace`. |
| `forkrail redirects publish|discard|versions|restore` | Publish staged redirects, or go back to a version. |
| `forkrail routes ls|add|update|rm|move|enable|disable|test` | Routing rules. `add NAME --src --src-syntax --action --dest --status --has --missing`. |
| `forkrail routes publish|discard|versions|restore|import|export` | Publish staged rules, or go back to a version. |
| `forkrail cache invalidate|dangerously-delete -p PROJECT --tag TAGS` | Purge by tag. `--target production|preview`, `--revalidation-deadline-seconds`. |
| `forkrail cache purge -p PROJECT` | Invalidate everything the project cached. |
| `forkrail cache ls PROJECT` | The latest purges. |

## Security, team and spend

| Command | Does |
| --- | --- |
| `forkrail firewall show|test|diff|publish|discard|versions|rollback PROJECT` | Look at, test and publish a project’s firewall. `--install` for the install’s own. |
| `forkrail firewall rule add|rm|on|off|move` | Custom rules: `--if`, `--and`, `--or`, `--then`, `--for`, rate limit options. |
| `forkrail firewall ip add|rm` | IP blocks. |
| `forkrail firewall attack-mode PROJECT --for 1h|6h|24h` | Challenge every visitor. `--off` to stop. |
| `forkrail firewall system-bypass add|rm`, `mitigations`, `limits`, `pause`, `resume` | DDoS mitigations and their exceptions. |
| `forkrail firewall enable|disable`, `import FILE` | Turn custom rules on or off, or import a Vercel firewall configuration. |
| `forkrail protection show|set PROJECT` | Deployment protection: `--scope`, `--members`, `--trusted-ips`, `--exceptions`, `--options-paths`, `--sign-out`. |
| `forkrail protection bypass add|rm PROJECT` | Bypass secrets for automation. `--env` also sets `FORKRAIL_AUTOMATION_BYPASS_SECRET`. |
| `forkrail protection default SCOPE` | The default scope for every project (owners). |
| `forkrail spend show|budget|no-budget|exempt|pause|resume` | Budgets and paused projects. |
| `forkrail owners ls|add|rm` | The install’s owners (needs AWS credentials). |
| `forkrail login [URL]`, `logout`, `whoami` | Sign a terminal in or out, and see who it is. |

## Monitor

| Command | Does |
| --- | --- |
| `forkrail logs PROJECT` | Requests, newest last. `--since`, `--status`, `--path`, `--host`, `-f`, `--request ID`, `--app`. |
| `forkrail stats PROJECT` | Status, latency, workers, cold starts and busiest paths. `--since 24h` by default. |
| `forkrail usage [PROJECT]` | Requests, function time, transfer and cost on AWS. `--since 30d`, `--daily`. |
| `forkrail routers` | Each router’s CPU, memory, disk, network and requests. |

## Install and administer

| Command | Does |
| --- | --- |
| `forkrail install` | Install forkrail in an AWS account. `--domain`, `--email`, `--check` (checks only), `--yes`, `--terminal`. Run it again to continue where it stopped. |
| `forkrail uninstall` | Delete everything `install` made. Asks you to type the domain unless `--yes`. |
| `forkrail dashboard [URL]` | Show or set the dashboard’s address. |
| `forkrail sweep` | List stored files no deployment uses; `--yes` deletes them. |
| `forkrail state status|mode|migrate|check` | Where project records are kept. |

## Environment variables the CLI reads

| Variable | Does |
| --- | --- |
| `FORKRAIL_TOKEN`, `FORKRAIL_API` | Sign in without a login file, for CI: the token and the dashboard’s address. |
| `FORKRAIL_AWS=1` | Use AWS credentials even when signed in. |
| `FORKRAIL_HOME_REGION` | The install’s home region. |
| `AWS_PROFILE` | The AWS profile, as in the AWS CLI. |
| `FORKRAIL_DASHBOARD_URL` | The dashboard’s address, for one command. |
| `FORKRAIL_CLOUDFLARE_TOKEN` | For `install --yes`: the Cloudflare API token for your domain’s DNS. |

---

# vercel.json reference

> forkrail reads the same `vercel.json` as Vercel. Here’s every key: what works, what’s ignored, and what stops a deploy so nothing behaves differently by surprise.

- Category: Reference
- URL: https://www.forkrail.com/docs/vercel-json

## Config files

Any one of `vercel.json`, `vercel.toml`, `vercel.ts`, `vercel.mts`, `vercel.js`, `vercel.mjs` or `vercel.cjs` works; two in one project stops the deploy, as on Vercel. A `vercel.ts` runs with Node when the project is read, and its `config` export (or default export) is used.

**vercel.ts**

```ts
import type { VercelConfig } from '@vercel/config/v1'

export const config: VercelConfig = {
  cleanUrls: true,
  crons: [{ path: '/api/cron/sync', schedule: '0 5 * * *' }],
}
```

## Supported keys

| Key | Notes | Docs |
| --- | --- | --- |
| `buildCommand`, `installCommand`, `outputDirectory`, `framework` | As on Vercel. | [Deploy](https://www.forkrail.com/docs/deploy) |
| `functions` | `memory`, `maxDuration`, `includeFiles`, `excludeFiles`, `architecture: "arm64"`, and a `runtime` naming the language’s own. | [Function settings](https://www.forkrail.com/docs/functions) |
| `fluid` | Concurrent compute on or off. | [Concurrent compute](https://www.forkrail.com/docs/concurrent-compute) |
| `crons`, `schedules` | Up to 100 a project; `schedules` targets a `path`. | [Cron jobs](https://www.forkrail.com/docs/cron-schedules) |
| `redirects`, `rewrites`, `headers`, `cleanUrls`, `trailingSlash`, `routes` | Vercel’s patterns, order and limits. | [Redirects and rewrites](https://www.forkrail.com/docs/routing) |
| `bulkRedirectsPath` | CSV, JSON or JSONL, up to 1,000,000. | [Bulk redirects](https://www.forkrail.com/docs/routing#bulk-redirects) |
| `images` | Vercel’s shape. | [Image Optimization](https://www.forkrail.com/docs/image-optimization) |
| `proxy` | Routing Middleware’s entry point and matcher. | [Middleware](https://www.forkrail.com/docs/middleware) |
| `git.deploymentEnabled`, `ignoreCommand` | Which pushes deploy. | [Deploy from GitHub](https://www.forkrail.com/docs/deploy-from-github) |
| `github.autoJobCancelation` | A newer push cancels older builds still running (default true). | [Deploy from GitHub](https://www.forkrail.com/docs/deploy-from-github) |
| `github.autoAlias` | `false`: production branch pushes build production deployments without moving production. | [Deployments](https://www.forkrail.com/docs/deployments-and-rollbacks) |

## Ignored keys

These are accepted and have no effect, with a warning where it matters: `version`, `regions` (use [function regions](https://www.forkrail.com/docs/function-regions)), `name`, the other `github` keys, `devCommand`, and `builds[].config.maxLambdaSize`.

## Refused keys

The deploy stops and names the key, rather than deploy something that behaves differently from Vercel:

- `builds` with more than one entry, or functions in `api/` in more than one language.
- `skipMiddlewareRequestBody`, `functionFailoverRegions`, `bunVersion`, and `public` (which Vercel dropped too).
- `schedules` that target anything but a `path`.
- In `routes`: `env` (in a route or a transform), `locale`, `middlewarePath`, and `handle: rewrite` or `resource`.
- Function settings other than the ones listed above.
- Keys that don’t fit the project: `fluid` on a static site, `outputDirectory` on an API.

---

# Limits

> Every limit in one place, next to Vercel’s where they differ. Most come from AWS Lambda, which runs your functions.

- Category: Reference
- URL: https://www.forkrail.com/docs/limits

## Functions and requests

| Limit | forkrail | Vercel Pro |
| --- | --- | --- |
| Function memory | 128 to 10,240 MB (default 640 MB) | Up to 4 GB |
| Max duration | 1 to 900 seconds (default 300) | Up to 800 seconds |
| Request body | 4.5 MB | 4.5 MB |
| Function size, unzipped | 250 MB | 250 MB |
| Env vars per environment | 64 KB | 64 KB |
| Header field | 32 KB (494 above) | 32 KB |
| Request headers in all | About 127.5 KB or 500 fields (431 above) | Similar |
| Middleware start | Its max duration, or 25 seconds | 25 seconds |
| Requests sharing one worker (concurrent compute) | 2 to 50 per worker (default 10), set per project; more workers start as needed | Set by Vercel |
| Workers per deployment | No cap by default (optional cap of 1 to 1,000); your account’s Lambda quota applies | Set by plan |

> **Your AWS account’s own limits:** Lambda limits apply per account and region: concurrency (1,000 by default) caps workers across all projects, and new accounts can start lower, including less memory per function. The installer adapts to what your account allows, and the dashboard’s function settings show the cap. Raise them in the AWS console under **Service Quotas → AWS Lambda**.

## Builds and deployments

| Limit | forkrail | Vercel Pro |
| --- | --- | --- |
| Build time | 15 minutes | 45 minutes |
| Build memory | 4 GB, then 8 GB for large builds | 8 GB |
| Upload | 100,000 files, 1 GB | By plan |
| Build cache kept | 30 days | By plan |
| Deployments kept | 30 days by default for each kind, configurable; production and recent ones always | By plan |
| Restore a deleted deployment | Within 30 days | Within 30 days |
| Deploy hooks | 5 a project, 60 calls an hour | By plan |

## Routing, caching and images

| Limit | forkrail |
| --- | --- |
| Items in each `vercel.json` routing key | 2,048, as on Vercel |
| Bulk redirects | 1,000,000 a project, as on Vercel |
| Cron schedules | 100 a project |
| Cached function answer | 10 MB |
| ISR page | 20 MB |
| Router disk cache | 2 GB per router |
| Source image | 8,192 pixels a side; 4 MB from a function, 50 MB from another site |
| Skew protection allowed domains | 12 |

## Firewall and protection

| Limit | forkrail |
| --- | --- |
| Firewall rules | 1,000, of which 100 rate limits |
| Rate limit window | 10 to 3,600 seconds |
| Attack mode | 1, 6 or 24 hours |
| Connections per address | 256 (owners can change it) |
| Requests per address | 5,000 in 10 seconds, then blocked 10 minutes (owners can change it) |
| System bypasses | 100 |
| Webhooks | 20 per install |

There’s no limit on projects, team members, domains, bandwidth or requests: you pay AWS for what you use, and [spend limits](https://www.forkrail.com/docs/spend-budgets) keep that in check.

---

# Error codes

> What each error forkrail answers with means, and how to fix it. Error responses carry the code in the `x-forkrail-error` header.

- Category: Reference
- URL: https://www.forkrail.com/docs/errors

## Codes

The names match Vercel’s where Vercel has the same error, so existing monitoring keeps working. Each error page also shows the request id, which you can look up with `forkrail logs PROJECT --request ID`.

| Status | Code | What happened, and what to do |
| --- | --- | --- |
| 404 | `DEPLOYMENT_NOT_FOUND` | No deployment answers on this host. Check the domain is added to a project and its DNS points at your install. |
| 404 | `NOT_FOUND` | The deployment has nothing at this path. Add the file or route, or a `404.html`. |
| 401 | `DEPLOYMENT_PROTECTED` | Deployment protection is on and the client has no access. Sign in, or send a [bypass secret](https://www.forkrail.com/docs/deployment-protection#automation). |
| 403 | `FORBIDDEN` | A firewall rule denied the request (`x-forkrail-mitigated: deny`). Check the Firewall page’s Blocked tab. |
| 403 | `CHALLENGE_FAILED` | The firewall’s challenge wasn’t passed. Use a browser, or exempt the client with a bypass rule. |
| 429 | `RATE_LIMITED` | A firewall rate limit was reached. Wait for `retry-after`, or raise the limit. |
| 429 | `TOO_MANY_REQUESTS` | One address sent more than the system mitigations allow. Add a [system bypass](https://www.forkrail.com/docs/firewall#ddos) for trusted traffic. |
| 413 | `FUNCTION_PAYLOAD_TOO_LARGE` | The request body is over 4.5 MB. Upload large files straight to S3 with a signed URL. |
| 494 | `REQUEST_HEADER_TOO_LARGE` | One header field is over 32 KB. Send less in cookies or headers. |
| 431 |  | Over 500 header fields, or about 127.5 KB of headers in all. Send fewer or smaller headers. |
| 500 | `FUNCTION_INVOCATION_FAILED` | Your function threw or crashed. Look at the request’s app output in Logs. |
| 504 | `FUNCTION_INVOCATION_TIMEOUT` | The function ran past its max duration. Raise [max duration](https://www.forkrail.com/docs/functions#max-duration), or move long work to a background job. |
| 500 | `MIDDLEWARE_INVOCATION_FAILED` | Middleware threw. Look at the request’s output in Logs. |
| 504 | `MIDDLEWARE_INVOCATION_TIMEOUT` | Middleware didn’t start answering within its time (25 seconds by default). Do less in middleware, or set its max duration. |
| 508 | `INFINITE_LOOP_DETECTED` | A request called the same project more than 5 levels deep, or over 1,000 times. Check rewrites and fetches that call your own site. |
| 503 | `DEPLOYMENT_PAUSED` | The project reached its [spend limit](https://www.forkrail.com/docs/spend-budgets). Raise the budget, then `forkrail spend resume`. |
| 504 | `ROUTER_EXTERNAL_TARGET_ERROR` | An external rewrite didn’t answer within 120 seconds. Check the other site. |
| 400 | `INVALID_IMAGE_OPTIMIZE_REQUEST` | An image request’s `url`, `w` or `q` isn’t allowed by `images`. Add the width to `sizes`, or the host to `remotePatterns`. |
| 416 | `RANGE_NOT_SATISFIABLE` | A `Range` lies outside the file. Request a range within the file. |
| 421 | `MISDIRECTED_REQUEST` | The request names two different hosts, or a port the router doesn’t answer on. Check the client’s URL and `Host` header. |
| 502 | `ROUTER_STATIC_UNAVAILABLE` | A static file couldn’t be read from S3. Retry; if it persists, check the install’s bucket in AWS. |

---

# Deploy SvelteKit on forkrail

> Keep `@sveltejs/adapter-vercel` or `adapter-auto` unchanged. forkrail imports the Build Output directly for SSR, streaming, ISR, image optimization, and skew protection inside your AWS account.

- Framework: SvelteKit
- Category: Websites & full-stack
- Status: Production ready
- Adapter / Preset: @sveltejs/adapter-vercel or adapter-auto
- Runtime: Node.js 24 (arm64) or Static S3
- Detection: package.json (@sveltejs/kit)
- Memory: 1,024 MB recommended for SSR
- URL: https://www.forkrail.com/frameworks/sveltekit

## Capabilities

| Capability | Support | Details |
| --- | --- | --- |
| SSR & streaming | Supported | Full streaming SSR, form actions, hooks, and $env |
| ISR caching | Supported | Per-route config.isr cached in the regional router |
| Image optimization | Supported | Adapter images config served via /_vercel/image |
| Skew protection | Supported | Enabled by default; pins open tabs to their deployment |

## 1. Configure your SvelteKit adapter

If your project already uses `@sveltejs/adapter-vercel` or `@sveltejs/adapter-auto`, nothing needs to change — forkrail sets `VERCEL=1` during builds so `adapter-auto` automatically selects Vercel’s adapter. Projects using `@sveltejs/adapter-static` deploy as zero-Lambda static sites served straight from S3.

**svelte.config.js**

```ts
import adapter from '@sveltejs/adapter-vercel'
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'

export default {
  preprocess: vitePreprocess(),
  kit: {
    adapter: adapter({
      images: {
        sizes: [640, 1080, 1920],
        formats: ['image/avif', 'image/webp'],
      },
    }),
  },
}
```

## 2. Deploy preview & production

Deploy from your terminal or connect the repository in **Settings → Git** for automatic branch previews. Because SSR is CPU-bound, 1,024 MB gives noticeably faster renders than the 640 MB default.

**Deploy SvelteKit with the CLI**

```bash
# Set recommended memory once for the project
forkrail project my-svelte-app --memory 1024

# Deploy a preview URL
forkrail deploy

# Ship to production
forkrail deploy --prod
```

## 3. ISR, split routes & client IP

Per-route `export const config` works as written for ISR (`expiration`, `bypassToken`, `allowQuery`), `memory`, and `maxDuration`. `event.getClientAddress()` always returns the visitor’s real IP (forkrail strips spoofed `x-forwarded-for` headers at the router).

**src/routes/blog/[slug]/+page.server.ts**

```ts
export const config = {
  isr: {
    expiration: 60,
  },
}

export async function load({ params }) {
  return { slug: params.slug, renderedAt: new Date().toISOString() }
}
```

> **Shared function memory for split routes:** With `split: true`, forkrail packs all route functions into one shared Lambda function sized to the largest `memory` requested while enforcing each route’s own `maxDuration` at the router. Files read with SvelteKit’s `read()` are bundled automatically.

## 4. Environment variables & AWS access

Add runtime secrets (`$env/dynamic/private`) and build-time variables (`$env/static/public`) through **Settings → Environment Variables** or `forkrail env add`. To reach S3, DynamoDB, or Bedrock without static IAM keys, attach an IAM role to the project (`forkrail project my-svelte-app --role my-app-role`).

## Related documentation

- [Image optimization](https://www.forkrail.com/docs/image-optimization.md)
- [Redirects, rewrites & headers](https://www.forkrail.com/docs/routing.md)
- [Environment variables](https://www.forkrail.com/docs/environment-variables.md)

---

# Deploy Astro on forkrail

> Deploy static Astro sites to S3 with zero Lambda cost, or add `@astrojs/vercel` for SSR, server islands, ISR caching, image optimization, and middleware.

- Framework: Astro
- Category: Websites & full-stack
- Status: Production ready
- Adapter / Preset: @astrojs/vercel (or none for static)
- Runtime: Node.js 24 (arm64) or Static S3
- Detection: package.json (astro)
- Memory: 1,024 MB for SSR · None for static
- URL: https://www.forkrail.com/frameworks/astro

## Capabilities

| Capability | Support | Details |
| --- | --- | --- |
| Static & hybrid SSR | Supported | Static pages from S3, on-demand routes & server islands on Lambda |
| ISR caching | Supported | adapter({ isr: true }) cached in the regional router |
| Image service | Supported | imageService: true routes through /_vercel/image |
| Edge middleware | Supported | edgeMiddleware & root middleware.ts run on Node workers |

## 1. Configure Astro (static or SSR)

For a purely static Astro site (`output: 'static'` with no server routes), no adapter is required — forkrail builds `dist/` and serves `/assets/` and `/_astro/` with immutable cache headers straight from S3. For SSR, Server Islands, or Actions, install `@astrojs/vercel`:

**astro.config.mjs**

```ts
import { defineConfig } from 'astro/config'
import vercel from '@astrojs/vercel'

export default defineConfig({
  output: 'server',
  adapter: vercel({
    isr: true,
    imageService: true,
  }),
})
```

**Install adapter**

```bash
npx astro add vercel
```

## 2. Deploy to forkrail

**Deploy preview and production**

```bash
# Preview deployment
forkrail deploy --memory 1024

# Production deployment
forkrail deploy --memory 1024 --prod
```

## 3. Server Islands, Actions & middleware

- **Server Islands & Actions:** Work out of the box on Node 24 arm64 with streaming responses and `Astro.clientAddress` populated from the router’s verified visitor IP.
- **ISR & Cache-Control:** Pages marked with `isr` cache at the regional router and share across regions over the router peer link. On-demand invalidation via `@vercel/functions` `invalidateByTag` works automatically.
- **`edgeMiddleware`:** Runs on Node inside your deployment’s Lambda workers while preserving the visitor’s original IP, geolocation headers, and firewall context.
- **Sessions:** Configure a session storage driver (such as DynamoDB, Redis, or ElastiCache inside your AWS account), just as on Vercel.

> **Use @astrojs/vercel rather than @astrojs/node:** forkrail imports Vercel’s Build Output API (`.vercel/output/`). Projects configured with `@astrojs/node`, Netlify, or Cloudflare adapters are refused at build time so nothing silently deploys with broken routing.

## Related documentation

- [Image optimization](https://www.forkrail.com/docs/image-optimization.md)
- [Redirects, rewrites & headers](https://www.forkrail.com/docs/routing.md)
- [Cron schedules](https://www.forkrail.com/docs/cron-schedules.md)

---

# Deploy Nuxt on forkrail

> Zero adapter setup: Nitro detects `VERCEL=1` at build time and emits its native Vercel preset, powering SSR, `routeRules` ISR/SWR, Nuxt Image, and static `/_nuxt/` delivery.

- Framework: Nuxt
- Category: Websites & full-stack
- Status: Production ready
- Adapter / Preset: Nitro built-in vercel preset (automatic)
- Runtime: Node.js 24 (arm64)
- Detection: package.json (nuxt)
- Memory: 1,024 MB recommended for SSR
- URL: https://www.forkrail.com/frameworks/nuxt

## Capabilities

| Capability | Support | Details |
| --- | --- | --- |
| SSR & Nitro routes | Supported | Zero-config Nitro vercel preset with routeRules |
| ISR & SWR caching | Supported | routeRules isr / swr cached directly by the router |
| Nuxt Image | Supported | Automatic /_vercel/image optimization |
| Skew protection | Supported | Supported via Nitro vercel preset cookie |

## 1. Configure routeRules & Nuxt Image

Nuxt needs no extra adapter package on forkrail. During the build, forkrail exports `VERCEL=1`, which tells Nitro to emit `.vercel/output/` automatically. Your `routeRules` (`isr`, `swr`, `redirect`, `headers`, `proxy`) execute at the regional router before Lambda wakes.

**nuxt.config.ts**

```ts
export default defineNuxtConfig({
  modules: ['@nuxt/image'],
  routeRules: {
    '/': { prerender: true },
    '/blog/**': { isr: 300 },
    '/products/**': { swr: 60 },
    '/old-docs/**': { redirect: '/docs' },
  },
})
```

> **Do not pin NITRO_PRESET=node-server:** Leave `nitro.preset` and `NITRO_PRESET` unset so Nitro selects its `vercel` preset. If a project explicitly pins `node-server`, forkrail runs `.output/server/index.mjs` as a single server, but router-level `isr`, `routeRules`, and `/_vercel/image` will not run at the router.

## 2. Deploy & set runtime secrets

Nuxt runtime config values (`NUXT_*` and `NUXT_PUBLIC_*`) are read from your project’s KMS-encrypted environment variables.

**Add secrets and deploy**

```bash
printf 'postgres://...' | forkrail env add my-nuxt-app NUXT_DATABASE_URL --target production
forkrail project my-nuxt-app --memory 1024
forkrail deploy --prod
```

## 3. Crons & function rules

Split heavy API endpoints with `nitro.vercel.functionRules` to grant them a longer `maxDuration`. For scheduled jobs in Nuxt (Nitro 2), define `crons` in `vercel.json` pointing to a server route in `server/api/cron/` and check `Authorization: Bearer $CRON_SECRET`.

## Related documentation

- [Cron schedules](https://www.forkrail.com/docs/cron-schedules.md)
- [Image optimization](https://www.forkrail.com/docs/image-optimization.md)
- [Environment variables](https://www.forkrail.com/docs/environment-variables.md)

---

# Deploy TanStack Start on forkrail

> First-class streaming SSR, Nitro v3 `scheduledTasks` crons, ISR route rules, and skew protection — forkrail’s own dashboard and website run on TanStack Start on forkrail.

- Framework: TanStack Start
- Category: Websites & full-stack
- Status: Production ready
- Adapter / Preset: nitro() Vite plugin (Nitro v3 vercel preset)
- Runtime: Node.js 24 (arm64) Web Fetch
- Detection: package.json (@tanstack/react-start)
- Memory: 1,024 MB recommended for SSR
- URL: https://www.forkrail.com/frameworks/tanstack-start

## Capabilities

| Capability | Support | Details |
| --- | --- | --- |
| Streaming SSR | Supported | Web Fetch handler with streaming HTML and server functions |
| ISR & route rules | Supported | Nitro routeRules cached by the regional router |
| Scheduled tasks | Supported | Nitro v3 scheduledTasks automatically register as crons |
| Skew protection | Supported | Enabled by default; keeps open sessions on matching assets |

## 1. Add Nitro to vite.config.ts

Include the `nitro()` plugin from `nitro/vite` alongside `tanstackStart()`. When forkrail builds your project with `VERCEL=1`, Nitro v3 outputs a Web `fetch` Build Output with immutable Vite asset caching and `context.waitUntil` support.

**vite.config.ts**

```ts
import { defineConfig } from 'vite'
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
import viteReact from '@vitejs/plugin-react'
import { nitro } from 'nitro/vite'

export default defineConfig({
  plugins: [
    nitro(),
    tanstackStart(),
    viteReact(),
  ],
})
```

## 2. Deploy preview & production

**Deploy TanStack Start**

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

If your server functions talk to AWS services (DynamoDB, S3, KMS, RDS) inside the same AWS account, assign a project IAM role with `forkrail project my-start-app --role my-app-role` instead of storing long-lived AWS keys in env vars.

## 3. Nitro scheduled tasks & prebuilt deploys

- **Cron tasks:** Nitro v3 `scheduledTasks` automatically translate into forkrail schedules calling `/_vercel/cron` (authenticated with `CRON_SECRET` when configured), alongside any `crons` in `vercel.json`.
- **Prebuilt deploys:** Already ran `npm run build` in CI? Ship `.vercel/output/` directly with `forkrail deploy --prebuilt`.
- **Concurrent compute:** Up to 10 simultaneous SSR and server-function requests share one warm Lambda worker over reverse HTTP/2.

## Related documentation

- [Concurrent compute](https://www.forkrail.com/docs/concurrent-compute.md)
- [Cron schedules](https://www.forkrail.com/docs/cron-schedules.md)
- [Function regions](https://www.forkrail.com/docs/function-regions.md)

---

# 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)

---

# Deploy Remix 2 on forkrail

> Deploy Remix 2 Vite projects with streaming loaders and actions, `vercelPreset()` route bundles, `vercel.json` routing, and CDN response caching in your AWS account.

- Framework: Remix
- Category: Websites & full-stack
- Status: Production ready
- Adapter / Preset: Vite plugin + optional vercelPreset() from @vercel/remix
- Runtime: Node.js 24 (arm64)
- Detection: package.json (@remix-run/dev)
- Memory: 1,024 MB recommended for SSR
- URL: https://www.forkrail.com/frameworks/remix

## Capabilities

| Capability | Support | Details |
| --- | --- | --- |
| Streaming SSR | Supported | Full Remix 2 Vite loaders, actions, and deferred streams |
| CDN caching | Supported | Route headers with s-maxage / CDN-Cache-Control cached at router |
| Routing middleware | Supported | Root middleware.ts and vercel.json redirects/rewrites |
| Classic compiler | Not supported | Requires Remix Vite plugin (classic remix.config.js not supported) |

## 1. Remix Vite configuration

forkrail packages Remix 2 Vite builds directly without modifying your app code. Add `vercelPreset()` from `@vercel/remix` if you split routes by `maxDuration` or `memory`:

**vite.config.ts**

```ts
import { vitePlugin as remix } from '@remix-run/dev'
import { vercelPreset } from '@vercel/remix/vite'
import { defineConfig } from 'vite'

export default defineConfig({
  plugins: [
    remix({
      presets: [vercelPreset()],
    }),
  ],
})
```

## 2. Deploy to preview or production

**Deploy with forkrail CLI**

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

> **Vite required & Node runtime:** Classic Remix projects using `remix.config.js` without Vite, and routes specifying `runtime: 'edge'`, are refused at build time. Migrate to the Remix Vite plugin and run routes on Node 24.

## Related documentation

- [Deployments & rollbacks](https://www.forkrail.com/docs/deployments-and-rollbacks.md)
- [Redirects, rewrites & headers](https://www.forkrail.com/docs/routing.md)
- [Environment variables](https://www.forkrail.com/docs/environment-variables.md)

---

# Deploy Vite & static SPAs on forkrail

> Zero Lambda functions, zero cold starts. forkrail builds `dist/`, stores assets by content hash in S3 across your active regions, and serves them directly from the regional Rust routers.

- Framework: Vite
- Category: Websites & full-stack
- Status: Production ready
- Adapter / Preset: None (auto-detects dist/)
- Runtime: Static S3 (no Lambda · optional api/ functions)
- Detection: package.json (vite)
- Memory: None (static delivery only)
- URL: https://www.forkrail.com/frameworks/vite

## Capabilities

| Capability | Support | Details |
| --- | --- | --- |
| Zero-Lambda serving | Supported | Served from router memory cache and regional S3 buckets |
| SPA fallback rewrites | Supported | Standard vercel.json catch-all rewrite to /index.html |
| Functions in api/ | Supported | Add Node, Python, Go, or Rust endpoints beside your SPA |
| Routing middleware | Supported | Optional root middleware.ts for auth, geo, or A/B routing |

## 1. Configure SPA routing (optional)

forkrail runs your `build` script and deploys `dist/` automatically (or any custom `outputDirectory` in `vercel.json`). For client-side routed single-page apps (React, Vue, Solid, Preact), add a catch-all rewrite to `/index.html`, just like on Vercel:

**vercel.json**

```json
{
  "rewrites": [
    { "source": "/(.*)", "destination": "/index.html" }
  ],
  "headers": [
    {
      "source": "/assets/(.*)",
      "headers": [
        { "key": "Cache-Control", "value": "public, max-age=31536000, immutable" }
      ]
    }
  ]
}
```

## 2. Deploy & set VITE_* build variables

Any environment variable added to the project is available during `vite build` (so `import.meta.env.VITE_*` embeds cleanly per environment — Preview vs Production).

**Set build env vars and deploy**

```bash
printf 'https://api.acme.dev' | forkrail env add web-spa VITE_API_URL --target production
forkrail deploy --prod
```

## 3. Add backend endpoints in api/

Need a few backend endpoints without standing up a separate service? Drop files in `api/` (for example `api/contact.ts` or `api/checkout.ts`) and forkrail serves `/api/*` alongside your Vite static files. See [Functions in api/](https://www.forkrail.com/docs/functions).

## Related documentation

- [Redirects, rewrites & headers](https://www.forkrail.com/docs/routing.md)
- [Functions in api/](https://www.forkrail.com/docs/functions.md)
- [Custom domains](https://www.forkrail.com/docs/domains.md)

---

# Deploy Next.js on forkrail

> Next.js 13.5 through 16 (App Router and Pages Router) builds without changing `next.config`, sharing one router-backed cache for ISR, RSC, and `revalidateTag`, plus router-served `/_next/image`.

- Framework: Next.js
- Category: Websites & full-stack
- Status: Beta
- Adapter / Preset: Automatic standalone + forkrail adapter (Next 15.5+)
- Runtime: Node.js 24 or 22 (arm64) · Static S3 for output: export
- Detection: package.json (next)
- Memory: 1,024–2,048 MB recommended
- URL: https://www.forkrail.com/frameworks/nextjs

## Capabilities

| Capability | Support | Details |
| --- | --- | --- |
| App & Pages Router | Supported | Next.js 13.5–16 SSR, streaming, Server Actions, Draft Mode |
| Shared router cache | Supported | ISR, fetch/use cache, revalidatePath & revalidateTag across workers |
| Image optimization | Supported | /_next/image handled by router with next.config image settings |
| Beta status | Partial | Works for previews & testing; 250 MB unzipped Lambda package limit |

## Honest beta status

> **Private beta for Next.js:** Next.js 13.5–16 builds, runs, shares a router-backed cache across workers, and persists `.next/cache` between builds. Conformance testing against Next.js’s upstream suite and container-image packaging for >250 MB apps are still underway — test thoroughly on preview URLs before moving critical production apps.

## 1. Zero changes to next.config

You do not need to edit `next.config` or add custom cache handlers. During the build, forkrail enables standalone output automatically (via `NEXT_ADAPTER_PATH` on Next 15.5+ or `NEXT_PRIVATE_STANDALONE=1`), seeds prerendered pages and RSC payloads directly into the router’s shared cache, and preserves `.next/cache` (including Turbopack/webpack caches and Server Actions encryption keys) for fast rebuilds.

If your config sets `output: 'export'`, forkrail leaves it alone and deploys the exported `out/` directory as a zero-Lambda static site while honoring `redirects()`, `rewrites()`, `headers()`, and `basePath`.

## 2. Deploy a Next.js preview

**Deploy and verify your Next.js app**

```bash
# Allocate generous memory for fast Next.js cold starts and SSR
forkrail project my-next-app --memory 1536

# Deploy a preview URL and test side by side
forkrail deploy

# Check logs and cache hits (x-vercel-cache: HIT / STALE / MISS)
forkrail logs my-next-app --app --follow
```

## 3. Current limits & tips

- **Supported versions:** Next.js 13.5 and later on Node 22 or 24 (set via `engines.node`). Next before 13.5 and Yarn Plug’n’Play (`nodeLinker: pnp`) are refused.
- **Package size limit:** Standalone output must stay under AWS Lambda’s 250 MB unzipped limit (the build log breaks down `node_modules` and largest files if exceeded).
- **Middleware matchers:** Exclude `_next/static` and static image paths from your `middleware.ts` matcher so the router serves static files and cached pages without waking Node.
- **Skew protection:** Works automatically on Next 14.1.4+ (and 13.5–14.1.3 with `experimental.useDeploymentId`).

## Related documentation

- [Moving from Vercel](https://www.forkrail.com/docs/moving-from-vercel.md)
- [Image optimization](https://www.forkrail.com/docs/image-optimization.md)
- [Logs & observability](https://www.forkrail.com/docs/logs-and-observability.md)

---

# Deploy FastAPI on forkrail

> Run ASGI FastAPI services on Python 3.12–3.14 arm64 with up to 10 concurrent requests per warm worker, zero Lambda adapter wrappers, and automatic dependency caching.

- Framework: FastAPI
- Category: APIs & backends
- Status: Production ready
- Adapter / Preset: None (native ASGI via uvicorn)
- Runtime: Python 3.13 arm64 (also 3.12 & 3.14)
- Detection: app.py / main.py / api/main.py or pyproject.toml
- Memory: 640 MB default (adjustable per project)
- URL: https://www.forkrail.com/frameworks/fastapi

## Capabilities

| Capability | Support | Details |
| --- | --- | --- |
| 10× concurrent ASGI | Supported | Up to 10 concurrent requests share one warm uvicorn worker |
| Dependency formats | Supported | pyproject.toml + uv.lock, Pipfile.lock, or requirements.txt |
| Zero wrapper code | Supported | No Mangum or AWS Lambda handler boilerplate needed |
| Streaming & SSE | Supported | StreamingResponse and Server-Sent Events stream end to end |

## 1. Project layout & entrypoint

forkrail automatically locates `app` in `app.py`, `index.py`, `server.py`, `main.py`, or `asgi.py` at the project root or under `src/`, `app/`, or `api/` — or specify an explicit module in `pyproject.toml`:

**api/main.py**

```python
from fastapi import FastAPI
from fastapi.middleware.gzip import GZipMiddleware

app = FastAPI()
app.add_middleware(GZipMiddleware, minimum_size=1000)

@app.get('/health')
async def health():
    return {'status': 'ok'}
```

**pyproject.toml**

```toml
[project]
name = "billing-api"
requires-python = ">=3.13"
dependencies = [
  "fastapi>=0.115",
  "httpx>=0.28",
]

[tool.vercel]
entrypoint = "api.main:app"
```

Pin your Python version in `.python-version` or `requires-python` (`3.12`, `3.13`, or `3.14`; defaults to `3.13`). Dependencies install for Linux arm64 manylinux wheels inside the builder and cache between deploys.

## 2. Deploy & tail logs

**Deploy FastAPI and inspect live traffic**

```bash
# Deploy a preview
forkrail deploy

# Ship to production
forkrail deploy --prod

# Stream requests, Python print/logging output, and outgoing HTTP calls
forkrail logs billing-api --app --follow
```

## 3. Concurrent compute & AWS connectivity

- **Async I/O shines:** Because uvicorn serves up to 10 concurrent streams per Lambda worker, FastAPI endpoints waiting on Postgres, Redis, or external APIs pay for one warm worker instead of ten.
- **Need strict isolation?** Set `"fluid": false` in `vercel.json` (or `forkrail project billing-api --concurrent false`) for one request per worker.
- **Keep startup fast:** Run slow warm-up work in FastAPI lifespan background tasks rather than blocking import time.
- **Private AWS services:** Assign an IAM role (`--role`) for boto3 without keys, or expose internal RDS/Postgres targets via `--egress`.

## Related documentation

- [Concurrent compute](https://www.forkrail.com/docs/concurrent-compute.md)
- [Logs & observability](https://www.forkrail.com/docs/logs-and-observability.md)
- [Environment variables](https://www.forkrail.com/docs/environment-variables.md)

---

# Deploy Django on forkrail

> Automatic `ASGI_APPLICATION` / `WSGI_APPLICATION` detection from `manage.py`, build-time `collectstatic` served by the router, KMS secrets, and same-account RDS access.

- Framework: Django
- Category: APIs & backends
- Status: Production ready
- Adapter / Preset: None (auto-reads manage.py settings module)
- Runtime: Python 3.13 arm64 (ASGI or 10-thread WSGI)
- Detection: manage.py + Django dependency
- Memory: 640–1,024 MB
- URL: https://www.forkrail.com/frameworks/django

## Capabilities

| Capability | Support | Details |
| --- | --- | --- |
| ASGI & WSGI | Supported | Native ASGI, or WSGI via a2wsgi (10 threads per worker) |
| collectstatic | Supported | Runs at build when STATIC_ROOT is set; router serves STATIC_URL |
| KMS secrets | Supported | SECRET_KEY and DATABASE_URL encrypted under your AWS KMS key |
| Cron management | Supported | Trigger maintenance endpoints from vercel.json schedules |

## 1. Prepare Django settings

forkrail inspects `manage.py` to find your settings module and boots `ASGI_APPLICATION` (or falls back to `WSGI_APPLICATION` running 10 concurrent threads under `a2wsgi`). Make sure `ALLOWED_HOSTS` allows your `.forkrail.com` preview hostnames and custom domains:

**config/settings.py**

```python
import os
from pathlib import Path

BASE_DIR = Path(__file__).resolve().parent.parent
SECRET_KEY = os.environ['DJANGO_SECRET_KEY']
DEBUG = False

ALLOWED_HOSTS = [
    '.forkrail.com',
    'app.acme.dev',
]

STATIC_URL = '/static/'
STATIC_ROOT = BASE_DIR / 'staticfiles'
```

Whenever `STATIC_ROOT` is configured, forkrail runs `collectstatic` during the build and uploads the static files to S3 so the regional router serves `STATIC_URL` without invoking Python (including `staticfiles.json` for manifest storage).

## 2. Store secrets & deploy

**Add Django environment variables and deploy**

```bash
printf 'django-insecure-replace-me' | forkrail env add portal DJANGO_SECRET_KEY --target production
printf 'postgres://user:pass@db.internal:5432/portal' | forkrail env add portal DATABASE_URL --target production

forkrail deploy --prod
```

> **Co-locate with your RDS database:** Set `"regions": ["iad1"]` (or whichever AWS region holds your RDS instance) in `vercel.json` so database queries stay inside one region with millisecond latency.

## Related documentation

- [Function regions](https://www.forkrail.com/docs/function-regions.md)
- [Environment variables](https://www.forkrail.com/docs/environment-variables.md)
- [Custom domains](https://www.forkrail.com/docs/domains.md)

---

# Deploy Flask on forkrail

> Drop in any Flask WSGI app — no Lambda adapters or custom handlers required. forkrail serves up to 10 concurrent requests per worker via `a2wsgi` and serves `public/` statics from S3.

- Framework: Flask
- Category: APIs & backends
- Status: Production ready
- Adapter / Preset: None (built-in a2wsgi + uvicorn shim)
- Runtime: Python 3.13 arm64 (also 3.12 & 3.14)
- Detection: app.py / index.py / api/index.py defining app
- Memory: 640 MB default
- URL: https://www.forkrail.com/frameworks/flask

## Capabilities

| Capability | Support | Details |
| --- | --- | --- |
| Zero-wrapper WSGI | Supported | Exports standard Flask `app` directly with no Mangum/Zappa |
| 10× concurrent threads | Supported | WSGI runs in 10 threads per warm worker via a2wsgi |
| Static files | Supported | Files in public/ served directly by the router from S3 |
| Vercel compatibility | Supported | Reads vercel.json routes, crons, and requirements.txt |

## 1. Entrypoint & dependencies

Define a top-level `app = Flask(__name__)` in `app.py`, `index.py`, `server.py`, `main.py`, or `wsgi.py` (at the root or in `src/`, `app/`, `api/`), and list dependencies in `requirements.txt`, `pyproject.toml`, or `Pipfile.lock`:

**app.py**

```python
from flask import Flask, jsonify

app = Flask(__name__)

@app.get('/api/status')
def status():
    return jsonify(ok=True, framework='flask')
```

**requirements.txt**

```text
flask==3.1.0
requests==2.32.3
```

## 2. Deploy to forkrail

**Deploy Flask preview and production**

```bash
forkrail deploy
forkrail deploy --prod
```

Every HTTP request, `print()` or `app.logger` line, and outgoing `requests` / `httpx` / `urllib` call appears in ClickHouse logs under the request’s trace ID.

## Related documentation

- [Logs & observability](https://www.forkrail.com/docs/logs-and-observability.md)
- [Firewall](https://www.forkrail.com/docs/firewall.md)
- [Spend budgets](https://www.forkrail.com/docs/spend-budgets.md)

---

# Deploy Express on forkrail

> Run existing Express apps on Node 24 arm64 with zero code changes — both `export default app` and `app.listen(process.env.PORT)` work, with TypeScript bundled automatically.

- Framework: Express
- Category: APIs & backends
- Status: Production ready
- Adapter / Preset: None (automatic Express launcher or PORT listener)
- Runtime: Node.js 24 or 22 (arm64)
- Detection: app / index / server (.ts|.js|.mjs) or package.json main
- Memory: 640 MB default
- URL: https://www.forkrail.com/frameworks/express

## Capabilities

| Capability | Support | Details |
| --- | --- | --- |
| Export or listen() | Supported | Accepts export default app or app.listen(process.env.PORT) |
| TypeScript ready | Supported | Bundled automatically with esbuild (respects type: module) |
| 10× concurrency | Supported | One warm Express process handles up to 10 concurrent requests |
| Public static files | Supported | Files in public/ served by the router before Express wakes |

## 1. Write or bring your Express app

forkrail detects Express from `package.json` and locates `app`, `index`, or `server` (at the root or in `src/`, in `.ts`, `.js`, `.mjs`, `.cjs`, `.mts`, `.cts`). Export the app directly or bind `process.env.PORT` — both styles work identically:

**src/index.ts**

```ts
import express from 'express'

const app = express()
app.use(express.json())

app.get('/api/health', (_req, res) => {
  res.json({ ok: true, runtime: process.version })
})

export default app
```

Need Node 22 instead of the Node 24 default? Set `"engines": { "node": "22.x" }` in `package.json`. `NODE_ENV=production` is automatically set for both previews and production so Express hides stack traces on error responses.

## 2. Deploy & configure limits

**Deploy Express and configure memory or timeouts**

```bash
forkrail deploy
forkrail deploy --prod

# Adjust memory or maxDuration for future deployments
forkrail project orders-api --memory 1024 --max-duration 60
```

## Related documentation

- [Concurrent compute](https://www.forkrail.com/docs/concurrent-compute.md)
- [Logs & observability](https://www.forkrail.com/docs/logs-and-observability.md)
- [Firewall](https://www.forkrail.com/docs/firewall.md)

---

# Deploy Hono on forkrail

> Export your Hono app directly with native TypeScript bundling, Web Fetch streaming, and up to 10 concurrent requests per warm Node 24 arm64 worker.

- Framework: Hono
- Category: APIs & backends
- Status: Production ready
- Adapter / Preset: None (native Web Fetch export default app)
- Runtime: Node.js 24 or 22 (arm64)
- Detection: src/index.ts, app.ts, index.ts, server.ts
- Memory: 640 MB default
- URL: https://www.forkrail.com/frameworks/hono

## Capabilities

| Capability | Support | Details |
| --- | --- | --- |
| Web Fetch standard | Supported | Zero adapter needed — just export default app |
| Native TypeScript | Supported | Compiled with esbuild during deploy |
| Streaming responses | Supported | stream(), streamText(), and streamSSE() stream directly |
| 10× concurrency | Supported | Shared warm workers keep tail latency and AWS cost low |

## 1. Export your Hono instance

forkrail detects Hono from `package.json` and runs any exported `{ fetch }` object through Web `Request` and `Response` automatically — no `@hono/node-server` wrapper required.

**src/index.ts**

```ts
import { Hono } from 'hono'

const app = new Hono()

app.get('/', (c) => c.json({ service: 'edge-api', status: 'ok' }))

app.get('/items/:id', (c) => {
  const id = c.req.param('id')
  return c.json({ id, country: c.req.header('x-vercel-ip-country') ?? 'unknown' })
})

export default app
```

## 2. Deploy to forkrail

**Deploy Hono**

```bash
forkrail deploy
forkrail deploy --prod
```

Prefer one file per endpoint instead of a single Hono router? Drop Web Fetch handlers directly inside `api/` — see [Functions in api/](https://www.forkrail.com/docs/functions).

## Related documentation

- [Functions in api/](https://www.forkrail.com/docs/functions.md)
- [Concurrent compute](https://www.forkrail.com/docs/concurrent-compute.md)
- [Function regions](https://www.forkrail.com/docs/function-regions.md)

---

# Deploy Go on forkrail

> Compile Go services and Vercel-style `api/*.go` handlers into static Linux arm64 binaries on Lambda `provided.al2023` with cached modules and tiny cold starts.

- Framework: Go
- Category: APIs & backends
- Status: Production ready
- Adapter / Preset: None (compiled static aarch64 binary)
- Runtime: AWS Lambda provided.al2023 (arm64)
- Detection: go.mod + main.go / cmd/api/main.go or api/*.go
- Memory: 256–640 MB (low footprint)
- URL: https://www.forkrail.com/frameworks/go

## Capabilities

| Capability | Support | Details |
| --- | --- | --- |
| Web server & api/ | Supported | Supports main.go listening on PORT or Vercel api/*.go handlers |
| Static arm64 build | Supported | Built with CGO_ENABLED=0 -ldflags="-s -w" and cached modules |
| Go toolchain detection | Supported | Respects go / toolchain directive in go.mod and vendor/ |
| 10× concurrent HTTP | Supported | Goroutines serve up to 10 concurrent streams per worker |

## 1. Choose a Go server or api/ handlers

forkrail supports both standard Go HTTP servers (at `main.go`, `cmd/api/main.go`, or `cmd/server/main.go`) and Vercel’s per-file `api/*.go` layout (where each file exports one `func(http.ResponseWriter, *http.Request)`):

**main.go (server)**

```go
package main

import (
	"fmt"
	"net/http"
	"os"
)

func main() {
	http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
		w.Header().Set("content-type", "application/json")
		fmt.Fprint(w, `{"ok":true}`)
	})

	port := os.Getenv("PORT")
	if port == "" {
		port = "8080"
	}
	http.ListenAndServe(":"+port, nil)
}
```

**api/hello.go**

```go
package handler

import (
	"fmt"
	"net/http"
)

func Handler(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("content-type", "application/json")
	fmt.Fprint(w, `{"message":"hello from go"}`)
}
```

## 2. Build flags & deploy

The builder compiles with `CGO_ENABLED=0` and `-ldflags="-s -w"` (customize with `GO_BUILD_FLAGS`), uses `-mod=vendor` when a `vendor/` directory exists, and caches Go modules across deployments.

**Deploy Go service**

```bash
forkrail deploy
forkrail deploy --prod
```

> **Logging note for compiled binaries:** Go binaries run without a language runtime shim: `stdout`/`stderr` lines attach to the active request when one request is in flight, while outgoing HTTP calls are not automatically intercepted.

## Related documentation

- [Functions in api/](https://www.forkrail.com/docs/functions.md)
- [Concurrent compute](https://www.forkrail.com/docs/concurrent-compute.md)
- [Function regions](https://www.forkrail.com/docs/function-regions.md)

---

# Deploy Rust on forkrail

> Cross-compile Axum, Actix-web, or Vercel `vercel_runtime` `[[bin]]` targets to native Linux arm64 with `cargo zigbuild --release`, cached Cargo registries, and sub-50 ms cold starts.

- Framework: Rust
- Category: APIs & backends
- Status: Production ready
- Adapter / Preset: None (Axum/Actix on PORT, or vercel_runtime [[bin]])
- Runtime: AWS Lambda provided.al2023 (aarch64 glibc 2.34)
- Detection: Cargo.toml ([[bin]] or server crate)
- Memory: 256–640 MB
- URL: https://www.forkrail.com/frameworks/rust

## Capabilities

| Capability | Support | Details |
| --- | --- | --- |
| Axum / Actix / Tokio | Supported | Any Rust HTTP server listening on process PORT |
| Vercel api/ binaries | Supported | Cargo [[bin]] endpoints with vercel_runtime unchanged |
| Cached cargo builds | Supported | Cargo registry and target/ persisted across deployments |
| Native arm64 speed | Supported | Compiled with cargo zigbuild --release for Amazon Linux 2023 |

## 1. Web server or vercel_runtime [[bin]]

Deploy a standard Rust HTTP server (such as Axum or Actix-web) listening on `PORT`, or keep Vercel’s `api/*.rs` `[[bin]]` layout using the `vercel_runtime` crate (forkrail passes `VERCEL_DEV_PORT` automatically):

**src/main.rs (Axum)**

```rust
use axum::{routing::get, Json, Router};
use serde_json::json;

#[tokio::main]
async fn main() {
    let app = Router::new()
        .route("/health", get(|| async { Json(json!({ "ok": true })) }));

    let port = std::env::var("PORT").unwrap_or_else(|_| "8080".into());
    let listener = tokio::net::TcpListener::bind(format!("0.0.0.0:{port}")).await.unwrap();
    axum::serve(listener, app).await.unwrap();
}
```

**Cargo.toml (api/ bins)**

```toml
[package]
name = "rust-api"
version = "0.1.0"
edition = "2024"

[[bin]]
name = "hello"
path = "api/hello.rs"

[dependencies]
vercel_runtime = "1"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
```

## 2. Deploy & cache builds

forkrail compiles releases with `cargo zigbuild --release` targeting Amazon Linux 2023’s glibc 2.34 (`aarch64-unknown-linux-gnu.2.34`) and caches both the Cargo registry and `target/` directory so incremental deploys stay fast.

**Deploy Rust service**

```bash
forkrail deploy
forkrail deploy --prod
```

## Related documentation

- [Functions in api/](https://www.forkrail.com/docs/functions.md)
- [Concurrent compute](https://www.forkrail.com/docs/concurrent-compute.md)
- [Spend budgets](https://www.forkrail.com/docs/spend-budgets.md)

---

# forkrail vs Vercel

> Everything you use Vercel for, in your own AWS account.

The workflow is the same: push to GitHub, get a preview URL, promote to production, roll back in seconds. The difference is where it runs. With forkrail, your apps, logs and secrets live in your AWS account, and AWS bills you directly.

- URL: https://www.forkrail.com/compare/vercel

## At a glance

| Aspect | forkrail | Vercel |
| --- | --- | --- |
| Where your apps run | Your own AWS account | Vercel’s cloud |
| Who bills you | AWS, at AWS prices | Vercel, per seat and per use |
| Where logs and secrets live | In your account, under your keys | In Vercel’s cloud |
| Config you bring | Your vercel.json, as it is | vercel.json |

## Feature by feature

### Ownership and billing

| Feature | forkrail | Vercel |
| --- | --- | --- |
| Where apps run | In your AWS account | In Vercel’s shared cloud |
| Billing | AWS bills you, with no markup; your AWS credits apply | Vercel bills you; AWS credits don’t apply |
| Logs and secrets | Stay in your account, encrypted with your own AWS keys | Kept in Vercel’s cloud unless you send them elsewhere |

### Running your apps

| Feature | forkrail | Vercel |
| --- | --- | --- |
| Many requests on one function | Up to 10 requests share one warm function | Functions can share instances across requests |
| Previews and rollbacks | A URL for every branch; roll back in about 5 seconds | A URL for every branch; instant rollback |
| Close to your AWS databases | Runs in the same AWS account as RDS, DynamoDB or SQS | Reaches them over the internet or extra network setup |

### Frameworks and config

| Feature | forkrail | Vercel |
| --- | --- | --- |
| SvelteKit, Astro, Nuxt, Remix and more | Built with the same adapters and vercel.json you use now | Supported |
| Next.js | Works, in beta | Fully supported (they make it) |
| Python, Node, Go and Rust APIs | FastAPI, Django, Flask, Express, Hono, Go, Rust and api/ functions | Supported |

### Safety and team

| Feature | forkrail | Vercel |
| --- | --- | --- |
| Spend limits | Metered as it happens; a project pauses at its budget | Alerts and pauses, checked periodically |
| Firewall | Custom rules, IP blocks, rate limits and attack mode | Custom rules, rate limits and attack mode |
| Team access | GitHub sign-in with roles; no AWS access needed; no seat fees | Team sign-in with roles; paid per seat |

## Which one fits

### Pick forkrail if

- Your apps, logs and secrets must stay in your own AWS account.
- Your databases or queues are already on AWS and you want one bill.
- You deploy SvelteKit, Astro, Nuxt, TanStack Start, React Router, Remix, Vite or Python, Node, Go and Rust APIs.
- You want a hard monthly spend limit that pauses a project, not just an alert.

### Pick Vercel if

- You need every new Next.js feature in production the day it ships.
- You don’t want anything running in an AWS account of your own.
- You rely on storage products that only exist inside Vercel.

---

# forkrail vs Netlify

> Netlify’s git-to-URL workflow, in your own AWS account.

Push to GitHub and get a preview link, just like Netlify. forkrail also runs full Python and Node APIs next to your sites, packs requests onto shared functions, and bills through your own AWS account.

- URL: https://www.forkrail.com/compare/netlify

## At a glance

| Aspect | forkrail | Netlify |
| --- | --- | --- |
| Where your apps run | Your own AWS account | Netlify’s cloud |
| Who bills you | AWS, at AWS prices | Netlify, by plan and usage |
| APIs you can run | Python, Node, Go and Rust | Mostly JavaScript and Go functions |
| Config you bring | vercel.json and framework adapters | netlify.toml and Netlify plugins |

## Feature by feature

### Ownership and billing

| Feature | forkrail | Netlify |
| --- | --- | --- |
| Where apps run | Everything runs in your AWS account | In Netlify’s shared cloud |
| Billing | AWS prices, no seat fees | Per seat, build minutes, bandwidth and invocations |

### Running your apps

| Feature | forkrail | Netlify |
| --- | --- | --- |
| Many requests on one function | Up to 10 requests share one warm function | One request per function |
| Previews and rollbacks | A URL for every branch; roll back in about 5 seconds | Deploy previews per pull request; instant rollback |

### Frameworks and config

| Feature | forkrail | Netlify |
| --- | --- | --- |
| Python APIs | FastAPI, Django and Flask | No Python functions |
| SvelteKit, Astro, Nuxt, Remix and more | Built with the adapters you already use | Supported with Netlify’s own adapters |

### Safety and team

| Feature | forkrail | Netlify |
| --- | --- | --- |
| Spend limits | A project pauses when it reaches its budget | Usage alerts |
| Logs and firewall | Searchable request logs, metrics, custom firewall rules | Function logs; advanced firewall on higher plans |

## Which one fits

### Pick forkrail if

- You want your sites and your Python or Node APIs in one place, in your AWS account.
- Your projects already use vercel.json rather than netlify.toml.
- Your APIs mostly wait on databases or other services, so sharing functions saves money.

### Pick Netlify if

- You use Netlify Forms, Identity or Blobs.
- You don’t want anything running in an AWS account of your own.

---

# forkrail vs AWS on your own

> Your AWS, without building a hosting platform first.

Teams that leave a hosting platform for plain AWS often end up maintaining CloudFront, API Gateway, Terraform and CI scripts by hand. forkrail runs in the same AWS account and gives you previews, logs, rollbacks and limits out of the box.

- URL: https://www.forkrail.com/compare/aws-diy

## At a glance

| Aspect | forkrail | AWS on your own |
| --- | --- | --- |
| Where your apps run | Your own AWS account | Your own AWS account |
| Who bills you | AWS | AWS |
| Work to keep it running | Installed once, nothing per project | Infrastructure code and CI for every project |
| What developers see | A dashboard with previews, logs and rollbacks | CI logs and the AWS console |

## Feature by feature

### Ownership and billing

| Feature | forkrail | AWS on your own |
| --- | --- | --- |
| Account and billing | Your account, your AWS bill | Your account, your AWS bill |

### Running your apps

| Feature | forkrail | AWS on your own |
| --- | --- | --- |
| Many requests on one function | Up to 10 requests share one warm function | One request per Lambda function |
| More than one region | Run in the regions you choose, behind one address | You build the failover, certificates and caching yourself |
| Preview URLs for branches | Automatic, with a comment on every pull request | You script stacks, DNS and cleanup in CI |

### Frameworks and config

| Feature | forkrail | AWS on your own |
| --- | --- | --- |
| Server rendering, images, middleware | Handled for each framework | Custom setup per framework |

### Safety and team

| Feature | forkrail | AWS on your own |
| --- | --- | --- |
| Logs | Every request searchable, with live tail; no CloudWatch bill | CloudWatch logs, function by function |
| Spend limits | A project pauses when it reaches its budget | AWS Budgets emails, often hours later |
| Team access | GitHub sign-in with roles; no AWS access needed | Everyone needs AWS access, or no dashboard |

## Which one fits

### Pick forkrail if

- Your engineers spend time fixing deploy pipelines instead of shipping.
- You want branch previews, live logs, quick rollbacks and team sign-in on top of your AWS.
- You want shared functions, spend limits and request logs without building them.

### Pick AWS on your own if

- Your system is mostly non-web workloads: queues, streams, batch jobs, GPUs.
- You have a platform team whose job is maintaining your own AWS tooling.
