---
title: "Runtime Selection"
description: "Configure runtime settings for your SvelteKit server functions on Vercel, including Node.js version, region selection, and Bun support."
canonical_url: "https://vercel.com/academy/svelte-on-vercel/runtime-selection"
md_url: "https://vercel.com/academy/svelte-on-vercel/runtime-selection.md"
docset_id: "vercel-academy"
doc_version: "1.0"
last_updated: "2026-10-02T17:46:31.308Z"
content_type: "lesson"
course: "svelte-on-vercel"
course_title: "Svelte on Vercel"
prerequisites:  []
---

<agent-instructions>
Vercel Academy — structured learning, not reference docs.
Lessons are sequenced.
Adapt commands to the human's actual environment (OS, package manager, shell, editor) — detect from project context or ask, don't assume.
The lesson shows one path; if the human's project diverges, adapt concepts to their setup.
Preserve the learning goal over literal steps.
Quizzes are pedagogical — engage, don't spoil.
Quiz answers are included for your reference.
</agent-instructions>

# Runtime Selection

# How Vercel Runs Your Functions

Your SvelteKit server code runs as Vercel Functions. Adapter 7 targets SvelteKit 3 and no longer supports the Edge runtime. New projects use Fluid compute by default, which lets multiple requests share an instance and reduces cold starts without requiring you to manage containers. You still control the Node.js version, deployment region, and optional runtimes such as Bun.

## Outcome

Add a health-check endpoint, configure the Node.js runtime version, and understand region selection for your SvelteKit functions.

## Fast Track

1. Know the default: SvelteKit on Vercel uses Node.js with Fluid compute
2. Set `runtime: 'nodejs24.x'` in the adapter config to pin a Node.js version
3. Use `regions` to control where your functions run

## Fluid Compute

Vercel's Fluid compute is the default for new projects. Instead of the traditional serverless model where each request spins up a new function instance, Fluid keeps your functions warm and reuses them across requests. The practical result: faster response times without any configuration.

|                   | Fluid (default)                                                 | Traditional Serverless   |
| ----------------- | --------------------------------------------------------------- | ------------------------ |
| **Cold starts**   | Minimal (functions stay warm)                                   | Every new instance       |
| **Concurrency**   | Handles multiple requests per instance                          | One request per instance |
| **Max duration**  | 300s by default; higher limits depend on plan and configuration | Lower limits may apply   |
| **Configuration** | None needed                                                     | None needed              |

The ski-alerts app can use Fluid compute without additional code. The AI chat endpoint benefits from instance reuse because streaming responses keep connections open while the model generates output.

## Hands-on Exercise 1.4

Explore runtime configuration for the ski-alerts app:

**Requirements:**

1. Add a health-check endpoint at `/api/health`
2. Pin the Node.js version in the adapter config
3. Verify the runtime settings in the Vercel dashboard after deploying

**Implementation hints:**

- Set runtime in `vite.config.ts` via `sveltekit({ adapter: adapter({ runtime: 'nodejs24.x' }) })`
- Per-route config is available by exporting a `config` object from `+server.ts` or `+page.server.ts`
- The health-check endpoint is a simple `GET` that returns JSON. You'll use it again in the observability lesson

**Global runtime in adapter config:**

```typescript title="vite.config.ts"
import adapter from '@sveltejs/adapter-vercel';
import { sveltekit } from '@sveltejs/kit/vite';
import tailwindcss from '@tailwindcss/vite';
import { defineConfig } from 'vite';

export default defineConfig({
  plugins: [
    tailwindcss(),
    sveltekit({ adapter: adapter({ runtime: 'nodejs24.x' }) })
  ]
});
```

## Try It

1. **Create the health-check endpoint:**

   ```typescript title="src/routes/api/health/+server.ts"
   import type { RequestHandler } from './$types';

   export const GET: RequestHandler = async () => {
     return Response.json({
       status: 'ok',
       timestamp: new Date().toISOString()
     });
   };
   ```

2. **Pin the Node.js version:**

   Update `vite.config.ts` to specify the runtime:

   ```typescript title="vite.config.ts"
   import adapter from '@sveltejs/adapter-vercel';
   import { sveltekit } from '@sveltejs/kit/vite';
   import tailwindcss from '@tailwindcss/vite';
   import { defineConfig } from 'vite';

   export default defineConfig({
     plugins: [
       tailwindcss(),
       sveltekit({ adapter: adapter({ runtime: 'nodejs24.x' }) })
     ]
   });
   ```

3. **Deploy and check the dashboard:**

   Push your changes and look at the **Functions** tab in your Vercel dashboard:

   ```
   /api/chat      → Node.js (Serverless)
   /api/health    → Node.js (Serverless)
   /api/evaluate  → Node.js (Serverless)
   /              → Node.js (Serverless)
   ```

4. **Hit the health endpoint:**
   ```bash
   $ curl https://ski-alerts-xxxxx.vercel.app/api/health
   {"status":"ok","timestamp":"2026-02-24T12:00:00.000Z"}
   ```

## Commit

```bash
git add -A
git commit -m "feat(runtime): add health endpoint and pin Node.js version"
git push
```

## Done-When

- [ ] `/api/health` returns a JSON response with status and timestamp
- [ ] `vite.config.ts` specifies a pinned Node.js runtime version
- [ ] The Vercel Functions tab shows all routes running on Node.js
- [ ] The health endpoint responds on your production URL

## Solution

**Health check endpoint:**

```typescript title="src/routes/api/health/+server.ts"
import type { RequestHandler } from './$types';

export const GET: RequestHandler = async () => {
  return Response.json({
    status: 'ok',
    timestamp: new Date().toISOString()
  });
};
```

**Adapter config with pinned runtime:**

```typescript title="vite.config.ts"
import adapter from '@sveltejs/adapter-vercel';
import { sveltekit } from '@sveltejs/kit/vite';
import tailwindcss from '@tailwindcss/vite';
import { defineConfig } from 'vite';

export default defineConfig({
  plugins: [
    tailwindcss(),
    sveltekit({ adapter: adapter({ runtime: 'nodejs24.x' }) })
  ]
});
```

Every route in the ski-alerts app runs on Node.js. The AI SDK, the Workflow SDK, and the weather service all run in that environment. Pinning `nodejs24.x` keeps the runtime consistent between deployments and provides native support for features such as `Object.groupBy()`.

## Troubleshooting

\*\*Warning: Build fails after changing the runtime version\*\*

Make sure the runtime string matches Vercel's supported versions. This course uses `nodejs24.x`; SvelteKit 3 requires Node.js 22.17 or newer. Check the [adapter documentation](https://svelte.dev/docs/kit/adapter-vercel) before choosing a different runtime.

\*\*Warning: Functions tab shows a different runtime than expected\*\*

Per-route `config` exports override the global adapter setting. If a specific route exports its own config, that takes precedence. Check the route file for a `config` export.

## Advanced: Region Configuration

By default, your functions deploy to a single region (usually `iad1`, US East). You can change this:

```typescript title="vite.config.ts" {3}
adapter({
  runtime: 'nodejs24.x',
  regions: ['sfo1'] // US West, closer to California ski resorts
})
```

For the ski-alerts app, choosing a region near your users or the Open-Meteo API servers can shave off latency on weather data fetches.

## Advanced: Bun Runtime

The SvelteKit Vercel adapter also supports Bun. Adapter 7 uses `bun1.x` as the runtime value:

```typescript title="vite.config.ts" {2}
adapter({
  runtime: 'bun1.x'
})
```

The [Bun runtime on Vercel](https://vercel.com/docs/functions/runtimes/bun) is in beta. Check its current feature support before switching an existing app. The ski-alerts app uses Node.js 24 throughout this course.


---

[Full course index](/academy/llms.txt) · [Sitemap](/academy/sitemap.md)
