CHAPTER 29
Beginner
Deploying Svelte Applications
Updated: May 18, 2026
5 min read
# CHAPTER 29
Deploying Svelte Applications
1. Chapter Introduction
Your Svelte app is built — now it needs to reach the world. This chapter covers the complete deployment workflow: building for production, configuring environment variables, and deploying to the three most popular platforms for Svelte: Vercel (official recommended), Netlify, and Firebase Hosting.2. Learning Objectives
- Build a production-optimized Svelte bundle.
- Configure environment variables securely.
- Deploy to Vercel (recommended for SvelteKit).
- Deploy to Netlify.
- Deploy to Firebase Hosting.
- Set up custom domains.
3. Production Build
bash
text
4. Environment Variables
bash
javascript
5. SvelteKit Adapters
SvelteKit needs an adapter that matches your deployment target:
bash
svelte.config.js
6. Deploying to Vercel
Method 1: Vercel CLI
bash
Method 2: GitHub Integration (recommended)
- 1. Push your project to GitHub.
-
2.
Go to
vercel.com→ New Project.
- 3. Import from GitHub.
- 4. Vercel auto-detects SvelteKit.
- 5. Add environment variables in Vercel dashboard.
- 6. Click Deploy — live in ~60 seconds!
Every git push to main auto-deploys!
7. Deploying to Netlify
bash
netlify.toml
GitHub Integration:
- 1. Push to GitHub.
-
2.
Go to
app.netlify.com→ New site from Git.
- 3. Select your repo.
-
4.
Build command:
npm run build, Publish dir:dist.
- 5. Add environment variables in Netlify settings.
8. Deploying to Firebase Hosting
bash
firebase.json
9. CI/CD with GitHub Actions
yaml
10. Performance Checklist for Production
text
11. MCQs
Question 1
What command creates a production build?
Question 2
What Vite prefix is required for env vars accessible in the browser?
Question 3
What is a SvelteKit adapter?
Question 4
What adapter is recommended for Vercel?
Question 5
What adapter creates a fully static site?
Question 6
What Netlify config file specifies build settings?
Question 7
Why do SPAs need a redirect rule on hosting?
Question 8
How does GitHub integration with Vercel/Netlify work?
Question 9
What does import.meta.env.VITEAPIURL return?
Question 10
Should .env be committed to version control?
12. Interview Questions
- Q: What is a SvelteKit adapter and why is it needed for different deployment targets?
- Q: How do you securely manage API keys in a Svelte application?