Skip to content
Get started

Core concepts

Five ideas cover most of what Vega does. Each links to a deeper guide or reference page.

An app is the unit you build and deploy. You create one with vega.app(), register routes on it, and export it:

api/index.ts
import { vega } from '@vega/sdk';
export const api = vega.app({ region: 'global' });
api.get('/health', () => Response.json({ ok: true }));

One project maps to one app. Larger surfaces stay organized with routers, which you mount under a path prefix.

Every handler receives a single context object instead of separate request/response arguments. It carries the parsed route params, query string, environment, and handles to the cache and the active trace:

api.get('/users/:id', async ({ params, query, cache, trace }) => {
trace.set('user.id', params.id);
const user = await cache.swr(`user:${params.id}`, () => db.users.find(params.id));
return Response.json(user);
});

Handlers return a standard Response. The full field list is in the routing reference.

Vega runs in 28 regions. With region: 'global', every deploy goes to all of them and requests are routed to the nearest one — typically 42ms p99 from major metros. You can also pin an app to specific regions, which is useful for data-residency requirements:

export const api = vega.app({ region: ['fra', 'lhr'] });

The Free tier deploys to 3 regions; Pro and Scale deploy to all 28.

vega deploy builds your entry file (typically in about 1.2s) and ships the artifact to every target region as an immutable deployment with a unique ID. Deployments never mutate: a rollback is just traffic moving back to a previous artifact, so it takes effect in under 10 seconds globally. Previews, promotion, and CI are covered in the deployments guide.

Two things are built into the runtime rather than bolted on:

  • Edge caching with stale-while-revalidate semantics, exposed as cache.swr(). Cached responses serve from memory in the region that received the request. See Edge caching.
  • Request-level tracing. Every request produces a trace with spans for your handler, cache operations, and outbound fetches — no agent or instrumentation step. See Observability.