Vercel and Netlify help you put your Svelte app online so anyone can visit it. They make sharing your work easy and fast.
You want to share your Svelte app with friends or clients quickly.
You finished building your Svelte project and want it live on the internet.
You want automatic updates when you change your code.
You want free hosting with simple setup for small to medium projects.
You want to use features like custom domains and HTTPS easily.
Syntax
Svelte
1. Push your Svelte project to a GitHub, GitLab, or Bitbucket repository.
2. Go to Vercel or Netlify website and sign up.
3. Connect your Git repository to Vercel or Netlify.
4. Choose your project and set build command: npm run build
5. Set publish directory: build (for SvelteKit) or dist (for Svelte)
6. Deploy and wait for the site to be live.
Build command and publish directory depend on your Svelte setup.
Both platforms watch your repo and redeploy on code changes automatically.
Examples
Typical for SvelteKit projects on Vercel or Netlify.
Svelte
Build command: npm run build
Publish directory: build
Used for basic Svelte projects without SvelteKit.
Svelte
Build command: npm run build
Publish directory: dist
Simple step-by-step flow for both Vercel and Netlify.
This shows the full flow from creating a SvelteKit app to deploying it on Vercel or Netlify.
Svelte
/* This is a deployment guide, not code to run. */1. Create a SvelteKit app:
npm create svelte@latest my-app
cd my-app
npm install
2. Test locally:
npm run dev
3. Push to GitHub:
git init
git add .
git commit -m "Initial commit"
git branch -M main
git remote add origin https://github.com/yourname/my-app.git
git push -u origin main
4. On Vercel or Netlify:
- Import project from GitHub
- Set build command: npm run build
- Set publish directory: build
- Deploy
5. Your app is live at the provided URL.
OutputSuccess
Important Notes
Make sure your package.json has a build script like "build": "vite build".
Check the deployment logs on Vercel or Netlify if something goes wrong.
Use environment variables on the platform dashboard for secrets or API keys.
Summary
Vercel and Netlify make it easy to put your Svelte app online.
Connect your Git repo, set build and publish settings, then deploy.
Your app updates automatically when you push new code.
Practice
(1/5)
1. What is the main purpose of using Vercel or Netlify with a Svelte app?
easy
A. To write Svelte code faster using special editors
B. To easily deploy and host the app online with automatic updates
C. To convert Svelte code into plain HTML manually
D. To debug Svelte apps without running them
Solution
Step 1: Understand deployment platforms
Vercel and Netlify are services that host web apps and update them automatically when code changes.
Step 2: Connect with Svelte app workflow
They connect to your Git repo, build your Svelte app, and publish it online without manual steps.
Final Answer:
To easily deploy and host the app online with automatic updates -> Option B
Quick Check:
Deployment = Easy hosting and updates [OK]
Hint: Think: Vercel/Netlify = online hosting + auto updates [OK]
Common Mistakes:
Confusing deployment with coding or debugging tools
Thinking they convert code manually
Assuming they only help with writing code
2. Which of the following is the correct step to deploy a Svelte app on Netlify?
easy
A. Set build command to 'npm run start' and publish directory to 'public'
B. Upload your Svelte files manually without any build settings
C. Connect Git repo and set build command to 'npm run build' with publish directory 'public/build'
D. Connect your Git repository, set build command to 'npm run build', and publish directory to 'build'
Solution
Step 1: Identify Netlify build settings for Svelte
Netlify needs the build command 'npm run build' to compile the app and the publish directory where the built files are stored.
Step 2: Know Svelte's default build output
Svelte outputs built files in 'public/build', so this should be the publish directory.
Final Answer:
Connect Git repo and set build command to 'npm run build' with publish directory 'public/build' -> Option C
Quick Check:
Netlify build = 'npm run build' + 'public/build' [OK]
Setting publish directory to 'build' instead of 'public/build'
Uploading files manually without build
3. Given this Vercel deployment setting for a Svelte app: Build Command: npm run build Output Directory: build What will happen when you push new code to Git?
medium
A. Vercel will build the app and deploy files from the 'build' folder
B. Vercel will fail because the output directory should be 'public/build'
C. Vercel will deploy the app but with old code only
D. Vercel will skip build and deploy source files directly
Solution
Step 1: Understand Vercel build and output settings
Vercel runs the build command to create production files, then deploys from the specified output directory.
Step 2: Check if 'build' is valid output directory
In many Svelte setups, the build output is in 'build' or 'public/build'. If 'build' is correct, deployment succeeds.
Final Answer:
Vercel will build the app and deploy files from the 'build' folder -> Option A
Forgetting to connect Git repo (would block deploy)
Confusing build command with publish directory
5. You want to deploy a Svelte app on Vercel with these requirements: - Use GitHub repo - Automatically rebuild on push - Serve from 'public' folder Which setup is correct?
hard
A. Connect GitHub repo, set build command 'npm run build', output directory 'public'
B. Connect GitHub repo, set build command 'npm run dev', output directory 'public/build'
C. Connect GitHub repo, set build command 'npm run build', output directory 'public/build'
D. Connect GitHub repo, no build command, output directory 'public'
Solution
Step 1: Understand Vercel deployment with GitHub
Connecting GitHub repo enables automatic rebuilds on push. The build command must create production files.
Step 2: Identify correct build command and output folder
'npm run build' builds the app. To serve from 'public' folder as required, output directory must be 'public'.
Final Answer:
Connect GitHub repo, set build command 'npm run build', output directory 'public' -> Option A