0
0
Svelteframework~5 mins

Vercel and Netlify deployment in Svelte

Choose your learning style9 modes available
Introduction

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.
Svelte
Connect GitHub repo -> Select project -> Set build & publish -> Deploy
Sample Program

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.