bantam.hostbantam.host
CLI Guide

Deploy SvelteKit with Bantam CLI

Deploy Svelte applications with adapter-static

Install Bantam CLI:

npm install -g @bantamhq/cli

View on NPM: @bantamhq/cli

Quick start:

# Build your SvelteKit app
npm run build

# Deploy it
bantam deploy build

Quick Start

1

Install adapter-static

Add the static adapter for SvelteKit

npm install -D @sveltejs/adapter-static
2

Build your site

Pre-renders all pages to static HTML

npm run build
This creates the build directory with your static files
3

Deploy with Bantam

Your SvelteKit site is now live!

bantam deploy build
Get an instant URL like https://my-sveltekit-app-abc123.bantam.site

Framework Details

Adapter Configuration

Configure SvelteKit to use the static adapter:

svelte.config.js:

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

/** @type {import('@sveltejs/kit').Config} */
const config = {
  kit: {
    adapter: adapter({
      pages: 'build',
      assets: 'build',
      fallback: undefined,
      precompress: false,
      strict: true
    })
  }
};

export default config;
The strict: true option ensures all pages can be pre-rendered.

Pre-rendering Routes

Mark pages for pre-rendering in your routes:

+page.js or +page.server.js:

export const prerender = true;

// For dynamic routes
export async function entries() {
  const posts = await getPosts();
  return posts.map(post => ({ slug: post.slug }));
}
Pages without export const prerender = true will fail to build with adapter-static.

Build Output

SvelteKit generates these in the build directory:

  • index.html - Pre-rendered HTML pages
  • _app/ - JavaScript bundles and chunks
  • favicon.png - Static assets
  • Pre-rendered HTML for each route
All JavaScript is optimally code-split for fast loading.

Advanced Usage

Custom Domain

Deploy directly to your own domain

bantam deploy ./dist --domain myapp.com

Permanent Deployment

Keep your site online forever (requires login)

bantam deploy ./dist --permanent

Custom Expiry

Set how long your deployment stays online

bantam deploy ./dist --expiry-days 7

Custom Subdomain

Choose your own subdomain on bantam.site

bantam deploy ./dist --subdomain my-project

CI/CD Integration

Add Bantam to your continuous deployment pipeline:

# GitHub Actions example
- name: Deploy to Bantam
  run: |
    npm install -g @bantamhq/cli
    bantam login --token ${{ secrets.BANTAM_TOKEN }}
    bantam deploy ./dist --domain myapp.com --permanent
Troubleshooting

Common Issues & Solutions

Quick fixes for deployment challenges

01.Error: Cannot prerender with dynamic server data?

Ensure all routes export prerender = true:

// +page.js
export const prerender = true;

// +layout.js (applies to all child routes)
export const prerender = true;

02.Dynamic routes not being generated?

Implement the entries function for dynamic routes:

// src/routes/blog/[slug]/+page.js
export const prerender = true;

export async function entries() {
  const posts = await fetch('/api/posts').then(r => r.json());
  return posts.map(post => ({ slug: post.slug }));
}

export async function load({ params }) {
  const post = await getPost(params.slug);
  return { post };
}

03.Form actions not working?

Static sites can't handle server-side form actions. Use client-side alternatives:

<!-- Instead of form actions -->
<script>
  async function handleSubmit(e) {
    e.preventDefault();
    const formData = new FormData(e.target);
    await fetch('/api/submit', {
      method: 'POST',
      body: formData
    });
  }
</script>

<form on:submit={handleSubmit}>
  <!-- form fields -->
</form>

04.Client-side routing not working?

Configure fallback for client-side routing:

// svelte.config.js
adapter: adapter({
  pages: 'build',
  assets: 'build',
  fallback: '200.html' // For SPA mode
})

Then create a _redirects file in your static folder:

/*    /200.html   200

05.Environment variables not working?

Use Vite's env variable system:

// .env
PUBLIC_API_URL=https://api.example.com

// In components
import { PUBLIC_API_URL } from '$env/static/public';

// Or dynamic
import { env } from '$env/dynamic/public';
console.log(env.PUBLIC_API_URL);