SvelteKit implementation checklist
A technical checklist for deploying SvelteKit applications to production, ensuring performance, security, and type safety across edge and serverless environments.
Deployment & Adapter Configuration
0/5Adapter Validation
criticalVerify svelte.config.js uses the correct adapter for the target environment (e.g., @sveltejs/adapter-cloudflare for Workers or @sveltejs/adapter-node for Docker).
Environment Variable Isolation
criticalEnsure all sensitive keys (Stripe secrets, DB strings) are imported from $env/static/private or $env/dynamic/private and never exposed in client-side code.
CSRF Origin Check
criticalSet the ORIGIN environment variable on Node-based adapters to match the production domain to prevent cross-site request forgery.
Node Engine Specification
recommendedDefine the engine version in package.json to match the deployment runtime (e.g., node: '>=20.0.0') to avoid runtime syntax errors.
Edge Runtime Compatibility
criticalIf using Cloudflare or Vercel Edge, verify that no Node-specific built-ins (fs, path, crypto) are used in server load functions.
Data Handling & Form Actions
0/5Progressive Enhancement
recommendedApply use:enhance to all <form> elements to ensure functionality when JavaScript is disabled or failing to load.
Server-side Validation
criticalValidate request.formData() using a schema library like Zod inside server actions before processing data.
Action Failure Handling
criticalUse the fail() helper to return 4xx status codes and validation errors instead of throwing generic 500 errors.
Database Connection Pooling
criticalConfigure Drizzle or your ORM to use a connection pooler (like PgBouncer) to prevent connection exhaustion in serverless environments.
Streaming Slow Data
recommendedReturn nested promises in load functions to stream non-critical data, preventing slow API calls from blocking the initial page paint.
Svelte 5 & State Management
0/5Rune Migration
recommendedReplace component-level writable stores with $state() runes to utilize the more efficient fine-grained reactivity system.
Strict Prop Typing
recommendedDefine all component inputs using the $props() rune with TypeScript interfaces for compile-time safety.
Effect Cleanup Logic
criticalVerify that all $effect() runes that initialize external listeners or timers return a cleanup function to prevent memory leaks.
Derived Logic Optimization
recommendedUse $derived() or $derived.by() for computed values to ensure they are only recalculated when their dependencies change.
Snippet Refactoring
optionalConvert repeated HTML patterns into @render snippets to reduce component overhead and improve maintainability.
Security & Authentication
0/5Lucia Session Lifecycle
criticalImplement session validation in the handle hook to ensure user state is globally accessible via event.locals.
Cookie Security Flags
criticalEnsure session cookies are configured with secure: true, httpOnly: true, and sameSite: 'lax' in production.
Content Security Policy
recommendedEnable and configure the csp object in svelte.config.js to restrict script sources and prevent XSS attacks.
Rate Limiting
recommendedApply rate-limiting logic to sensitive routes like /login or AI-generation endpoints using a Redis-based middleware.
Input Sanitization
criticalManually sanitize any user-provided string that is rendered using the {@html} tag to prevent script injection.
Performance & Optimization
0/5Static Pre-rendering
recommendedExport const prerender = true for all routes that do not contain user-specific data to serve them via CDN.
Image Optimization
recommendedUse a specialized image component or Vite plugin to serve WebP/AVIF formats and prevent layout shifts with fixed aspect ratios.
Font Preloading
optionalAdd <link rel="preload"> tags in app.html for critical brand fonts to minimize Flash of Unstyled Text (FOUT).
Cache-Control Headers
recommendedSet appropriate setHeaders() in server load functions for public assets to leverage browser and edge caching.
Bundle Analysis
recommendedRun vite-bundle-visualizer and remove any large libraries that can be replaced with native browser APIs or smaller alternatives.
SEO & Monitoring
0/5Dynamic Meta Tags
recommendedImplement a <svelte:head> block in +layout.svelte or +page.svelte that pulls title and description from the load function data.
Canonical URL Implementation
recommendedEnsure every page renders a <link rel="canonical"> tag based on the current page URL to avoid duplicate content penalties.
Sitemap Generation
recommendedConfigure an endpoint at /sitemap.xml that dynamically lists all crawlable routes using a library like super-sitemap.
Error Tracking Integration
criticalInitialize Sentry or a similar service in hooks.server.ts and hooks.client.ts to capture runtime exceptions.
Robots.txt Presence
recommendedVerify that static/robots.txt exists and correctly points to the sitemap URL.