Skip to main content
The @sveltejs/adapter-auto adapter automatically detects your production environment and selects the appropriate adapter for deployment.

Installation

npm install -D @sveltejs/adapter-auto

Usage

Add the adapter to your svelte.config.js:
/// file: svelte.config.js
import adapter from '@sveltejs/adapter-auto';

/** @type {import('@sveltejs/kit').Config} */
const config = {
  kit: {
    adapter: adapter()
  }
};

export default config;

How it works

When you build your app, adapter-auto detects the environment by checking for specific environment variables and installs the appropriate adapter automatically:
1

Environment detection

Checks for platform-specific environment variables (e.g., VERCEL, CF_PAGES, NETLIFY)
2

Adapter installation

Automatically installs the detected adapter if not already present
3

Build execution

Runs the selected adapter to generate platform-specific output

Supported environments

The adapter automatically detects and supports the following platforms:
// Detects: process.env.VERCEL
// Installs: @sveltejs/adapter-vercel
Refer to the adapter source code for the complete list:
/// file: packages/adapter-auto/adapters.js
export const adapters = [
  {
    name: 'Vercel',
    test: () => !!process.env.VERCEL,
    module: '@sveltejs/adapter-vercel',
    version: '6'
  },
  {
    name: 'Cloudflare Pages',
    test: () => !!process.env.CF_PAGES,
    module: '@sveltejs/adapter-cloudflare',
    version: '7'
  },
  {
    name: 'Netlify',
    test: () => !!process.env.NETLIFY,
    module: '@sveltejs/adapter-netlify',
    version: '6'
  }
  // ... additional adapters
];

When to use adapter-auto

Good for: Quick starts, prototyping, and projects that deploy to a single, well-known platform.Not ideal for: Production apps where you want explicit control over deployment configuration or need to customize adapter options.

Replacing adapter-auto

For production deployments, consider replacing adapter-auto with a specific adapter:
/// file: svelte.config.js
// Before
import adapter from '@sveltejs/adapter-auto';

// After - for Vercel
import adapter from '@sveltejs/adapter-vercel';

/** @type {import('@sveltejs/kit').Config} */
const config = {
  kit: {
    adapter: adapter({
      // Now you can configure adapter-specific options
      runtime: 'nodejs24.x',
      regions: ['iad1']
    })
  }
};

export default config;
When you build with adapter-auto, it will warn you and suggest which adapter to use for your detected environment.

Limitations

Certain features are not available with adapter-auto because it cannot determine environment capabilities:
// These will throw errors with adapter-auto:
import { read } from '$app/server';

// Error: "The read function imported from $app/server only works 
// in certain environments. Since you're using @sveltejs/adapter-auto, 
// SvelteKit cannot determine whether it will work when your app is deployed."
If your app uses read from $app/server or instrumentation.server.js, you must use a specific adapter instead of adapter-auto.