0
0
Svelteframework~5 mins

Static adapter deployment in Svelte

Choose your learning style9 modes available
Introduction

Static adapter deployment helps you turn your Svelte app into simple files that any web server can serve. It makes your app fast and easy to share without needing a special server.

You want to host your Svelte app on GitHub Pages or Netlify.
You need a fast website that loads quickly without a backend.
You want to share your app as static files without server setup.
You are building a blog or portfolio that doesn't need dynamic server code.
Syntax
Svelte
import adapter from '@sveltejs/adapter-static';

export default {
  kit: {
    adapter: adapter({
      // options here
    })
  }
};
The adapter is added in the svelte.config.js file inside the kit.adapter property.
You can pass options like pages and assets to control output folders.
Examples
Basic setup with default options for static deployment.
Svelte
import adapter from '@sveltejs/adapter-static';

export default {
  kit: {
    adapter: adapter()
  }
};
Custom output folder build and no fallback page for SPA routing.
Svelte
import adapter from '@sveltejs/adapter-static';

export default {
  kit: {
    adapter: adapter({
      pages: 'build',
      assets: 'build',
      fallback: null
    })
  }
};
Sample Program

This config sets up the static adapter to output all files into the build folder. It uses index.html as a fallback page for client-side routing, so your app works well on static hosts.

Svelte
import adapter from '@sveltejs/adapter-static';

export default {
  kit: {
    adapter: adapter({
      pages: 'build',
      assets: 'build',
      fallback: 'index.html'
    })
  }
};
OutputSuccess
Important Notes

Static adapter does not support server-side code like API routes.

Use fallback option to enable SPA style routing on static hosts.

Check your hosting service docs for how to upload static files.

Summary

Static adapter turns your Svelte app into simple files for easy hosting.

Configure it in svelte.config.js under kit.adapter.

Great for blogs, portfolios, and sites without backend needs.