All posts

Svelte Application Deployment Checklist

Complete Svelte deployment checklist covering SvelteKit adapters, build optimization, environment configuration, and production monitoring.

Svelte Application Deployment Checklist

SvelteKit offers multiple deployment targets. Here's what to verify before going live.

Choose the Right Adapter

// svelte.config.js
import adapter from '@sveltejs/adapter-node'; // For Node.js servers
// import adapter from '@sveltejs/adapter-vercel';  // For Vercel
// import adapter from '@sveltejs/adapter-static';  // For static hosting

export default {
  kit: {
    adapter: adapter({
      out: 'build',
      precompress: true, // Generates .gz and .br files
    }),
  },
};
  • [ ] Adapter matches hosting platform
  • [ ] Precompression enabled for static assets
  • [ ] SSR configured correctly per route

Build Verification

npm run build
npm run preview  # Test production build locally
  • [ ] Production build completes without errors
  • [ ] Build output size is reasonable
  • [ ] All routes load correctly in preview mode
  • [ ] Dynamic imports and code splitting working

Environment Variables

// Only $env/static/public variables are client-accessible
import { PUBLIC_API_URL } from '$env/static/public';

// Server-only variables
import { DATABASE_URL } from '$env/static/private';
  • [ ] All environment variables set on hosting platform
  • [ ] No private variables exposed to client
  • [ ] $env/static used for build-time values
  • [ ] $env/dynamic used for runtime values

Error Handling

// src/hooks.server.ts
export function handleError({ error, event }) {
  console.error('Server error:', error);
  return {
    message: 'An unexpected error occurred',
    code: 'INTERNAL_ERROR',
  };
}
  • [ ] hooks.server.ts error handler configured
  • [ ] hooks.client.ts error handler configured
  • [ ] Custom error pages created (+error.svelte)
  • [ ] Error tracking with Bugsly for production visibility

Performance

  • [ ] Prerendering enabled for static pages
  • [ ] Image optimization configured
  • [ ] Font loading optimized (preload critical fonts)
  • [ ] Third-party scripts loaded asynchronously

Security

  • [ ] CSP headers configured in hooks.server.ts
  • [ ] CSRF protection enabled
  • [ ] Form actions validate input server-side
  • [ ] Rate limiting on form actions

Infrastructure

  • [ ] Health check endpoint available
  • [ ] SSL/TLS configured
  • [ ] CDN in front of static assets
  • [ ] Monitoring and alerting set up

Try Bugsly Free

AI-powered error tracking that explains your bugs. Set up in 2 minutes, free forever for small projects.

Get Started Free