Deploy to Netlify
Deploy your SvelteBolt application to Netlify with serverless functions support in under 10 minutes.
Prerequisites
- SvelteBolt project ready locally
- GitHub/GitLab account with your code pushed
- Netlify account (free tier available)
- Supabase project configured with database schema and auth enabled
- Stripe account with API keys (for payments)
Step 1: Prepare SvelteKit for Netlify
SvelteBolt uses adapter-auto
by default, which automatically detects the deployment platform and installs the appropriate adapter. For Netlify, this means @sveltejs/adapter-netlify
will be installed automatically during the build process.
However, if you want to configure Netlify-specific options, you can explicitly install and configure the Netlify adapter:
import adapter from "@sveltejs/adapter-netlify";
import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";
/** @type {import('@sveltejs/kit').Config} */
const config = {
preprocess: vitePreprocess(),
kit: {
adapter: adapter({
edge: false,
split: false,
}),
},
};
export default config;
Install Netlify adapter (optional):
bun add -D @sveltejs/adapter-netlify
# or
npm install -D @sveltejs/adapter-netlify
Note: The respective adapter will be installed by default when you use
adapter-auto
, but adding it to your project allows you to specify Netlify-specific options likeedge
andsplit
configuration.
Step 2: Connect Repository
- Go to netlify.com and sign in
- Click "Add new site" → "Import an existing project"
- Connect your Git provider:
- Connect GitHub/GitLab if not already connected
- Choose your SvelteBolt repository
- Click "Deploy site"
Step 3: Configure Build Settings
Netlify should auto-detect, but verify these settings:
Build command: bun run build
(or npm run build
)
Publish directory: build
Functions directory: build/server
(auto-configured)
Step 4: Environment Variables
Add environment variables in Netlify dashboard:
- Go to Site settings → Environment variables
- Add each variable:
# Supabase (Required - Main Database)
PUBLIC_SUPABASE_URL=https://your-project.supabase.co
PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6...
SUPABASE_SERVICE_ROLE_SECRET=eyJhbGciOiJIUzI1NiIsInR5cCI6...
# Stripe (Required for payments)
PUBLIC_STRIPE_KEY=pk_live_51ABC123...
STRIPE_SECRET_KEY=sk_live_51ABC123...
STRIPE_WEBHOOK_SECRET=whsec_ABC123...
- Choose deployment context:
- All (production and deploy previews)
- Production (live site only)
- Deploy previews (branch previews only)
Step 5: Deploy
- Click "Deploy site"
- Wait 3-5 minutes for build to complete
- Your app will be live at
https://random-name.netlify.app
Step 6: Update Stripe Webhooks
Important: Update your Stripe webhook URL:
- Go to Stripe Dashboard → Developers → Webhooks
- Select your webhook endpoint
- Update the URL to:
https://your-site.netlify.app/api/stripe/webhook
- Save changes
Step 7: Configure Supabase for Production
Important: Add your Netlify domain to Supabase settings:
- Go to Supabase Dashboard → Authentication → URL Configuration
- Add Site URL:
https://your-site.netlify.app
- Add Redirect URLs:
https://your-site.netlify.app/auth/callback
https://your-site.netlify.app/auth/confirm
- Save configuration
For custom domains:
- Update Site URL to your custom domain
- Add custom domain to redirect URLs
- Update any hardcoded URLs in your app
Custom Domain (Optional)
- In Netlify dashboard, go to Site settings → Domain management
- Add custom domain
- Configure DNS as instructed
- SSL automatically enabled
- Update Stripe webhook URL to use custom domain
Netlify Features
Deploy Previews
- Every pull request gets a unique preview URL
- Test changes before merging to main
- Share previews with team members
Branch Deploys
- Deploy specific branches for staging
- Set up staging environment from development branch
- Test features in isolation
Troubleshooting
Common SvelteKit + Netlify Issues
❌ "Function invocation failed" errors:
# Add to netlify.toml
[build]
command = "bun run build"
functions = "build/server"
[functions]
node_bundler = "esbuild"
❌ Build fails with adapter error:
# Ensure correct adapter in svelte.config.js
import adapter from '@sveltejs/adapter-netlify';
❌ API routes timing out:
- Netlify functions have 10s timeout (free tier)
- Optimize database queries
- Consider upgrading to Pro for 26s timeout
❌ Environment variables not available:
- Check variables are set for correct deployment context
- Redeploy after adding new variables
- Verify naming matches exactly (case-sensitive)
❌ Large bundle size issues:
# Add to netlify.toml
[build]
environment = { NODE_OPTIONS = "--max_old_space_size=4096" }
❌ Supabase connection issues:
- Add your Netlify domain to Supabase CORS settings
- Include both
https://your-site.netlify.app
and custom domain - Verify database schema is properly migrated
- Check if Row Level Security (RLS) policies are correctly configured
- Ensure Supabase project is not paused (free tier limitation)
- Test Supabase connection with a simple query first
- Check if auth providers are enabled in Supabase dashboard
- Verify email templates are configured for auth flows
- Ensure service role key has correct permissions
Performance Optimization
Add netlify.toml for optimization:
[build]
command = "bun run build"
functions = "build/server"
[functions]
node_bundler = "esbuild"
[[headers]]
for = "/build/*"
[headers.values]
Cache-Control = "public, immutable, max-age=31536000"
[[headers]]
for = "*.js"
[headers.values]
Cache-Control = "public, max-age=31536000"
[[redirects]]
from = "/api/*"
to = "/.netlify/functions/:splat"
status = 200
Edge Functions (Optional)
For ultra-fast response times, use Netlify Edge Functions:
// netlify/edge-functions/api.js
export default async (request, context) => {
// Your API logic here
return new Response("Hello from the edge!");
};
export const config = {
path: "/api/edge/*",
};
Monitoring
Check these after deployment:
✅ Site loads correctly at your Netlify URL
✅ Authentication works (login/signup)
✅ Stripe payments process successfully
✅ Webhooks receive events (check function logs)
✅ Database connections work
✅ API routes respond correctly
✅ Form submissions work (if using Netlify forms)
Monitor in Netlify dashboard:
- Functions tab for serverless function logs
- Deploys tab for build history
- Analytics for traffic insights
Next Steps
- Set up environment secrets properly
- Configure custom domain
- Set up branch deploys for staging
- Monitor function performance and costs