Bird
Raised Fist0
Svelteframework~10 mins

Vercel and Netlify deployment in Svelte - Interactive Code Practice

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the build command for Vercel deployment in vercel.json.

Svelte
{
  "builds": [
    { "src": "package.json", "use": "[1]" }
  ]
}
Drag options to blanks, or click blank then click option'
A@vercel/node
B@vercel/python
C@vercel/svelte
D@vercel/static-build
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a server runtime builder instead of static build.
2fill in blank
medium

Complete the netlify.toml to set the build command for Netlify deployment.

Svelte
[build]
command = "[1]"
publish = "build"
Drag options to blanks, or click blank then click option'
Anpm run start
Bnpm run build
Cnpm install
Dnpm run dev
Attempts:
3 left
💡 Hint
Common Mistakes
Using start or dev commands instead of build.
3fill in blank
hard

Fix the error in the Netlify publish directory setting to correctly point to the Svelte build output.

Svelte
[build]
publish = "[1]"
Drag options to blanks, or click blank then click option'
Asrc
Bdist
Cbuild
Dpublic
Attempts:
3 left
💡 Hint
Common Mistakes
Using source or public folders instead of build.
4fill in blank
hard

Fill both blanks to configure environment variables for Vercel deployment in vercel.json.

Svelte
{
  "env": {
    "API_URL": "[1]",
    "NODE_ENV": "[2]"
  }
}
Drag options to blanks, or click blank then click option'
Ahttps://api.example.com
Bproduction
Cdevelopment
Dhttp://localhost:3000
Attempts:
3 left
💡 Hint
Common Mistakes
Using localhost URL or development environment in production.
5fill in blank
hard

Fill all three blanks to complete the SvelteKit adapter import and usage for Netlify deployment in svelte.config.js.

Svelte
import adapter from '@sveltejs/adapter-netlify';

export default {
  kit: {
    adapter: adapter({
      [1]: true,
      [2]: true,
      [3]: 10
    })
  }
};
Drag options to blanks, or click blank then click option'
Asplit
Bedge
Dtimeout
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing option names or values.

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

  1. Step 1: Understand deployment platforms

    Vercel and Netlify are services that host web apps and update them automatically when code changes.
  2. Step 2: Connect with Svelte app workflow

    They connect to your Git repo, build your Svelte app, and publish it online without manual steps.
  3. Final Answer:

    To easily deploy and host the app online with automatic updates -> Option B
  4. 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

  1. 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.
  2. Step 2: Know Svelte's default build output

    Svelte outputs built files in 'public/build', so this should be the publish directory.
  3. Final Answer:

    Connect Git repo and set build command to 'npm run build' with publish directory 'public/build' -> Option C
  4. Quick Check:

    Netlify build = 'npm run build' + 'public/build' [OK]
Hint: Remember: build command builds, publish points to output folder [OK]
Common Mistakes:
  • Using 'npm run start' instead of 'npm run build'
  • 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

  1. Step 1: Understand Vercel build and output settings

    Vercel runs the build command to create production files, then deploys from the specified output directory.
  2. 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.
  3. Final Answer:

    Vercel will build the app and deploy files from the 'build' folder -> Option A
  4. Quick Check:

    Build + correct output folder = successful deploy [OK]
Hint: Build command + correct output folder = deploy success [OK]
Common Mistakes:
  • Assuming output directory must be 'public/build' always
  • Thinking Vercel deploys source files without build
  • Confusing build failure with deployment failure
4. You deployed a Svelte app on Netlify but the site shows a 404 error after deployment. What is the most likely cause?
medium
A. The build command is set to 'npm run start' instead of 'npm run build'
B. The Git repository is empty and has no code
C. You forgot to connect your Git repo to Netlify
D. The publish directory is set incorrectly, so Netlify can't find the built files

Solution

  1. Step 1: Analyze 404 error cause on Netlify

    A 404 after deployment usually means Netlify can't find the files to serve, often due to wrong publish directory.
  2. Step 2: Check common misconfigurations

    If the publish directory is wrong, Netlify deploys an empty or wrong folder, causing 404 errors.
  3. Final Answer:

    The publish directory is set incorrectly, so Netlify can't find the built files -> Option D
  4. Quick Check:

    404 on deploy = wrong publish directory [OK]
Hint: 404 after deploy? Check publish directory first [OK]
Common Mistakes:
  • Assuming empty Git repo causes 404 (usually build fails first)
  • 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

  1. Step 1: Understand Vercel deployment with GitHub

    Connecting GitHub repo enables automatic rebuilds on push. The build command must create production files.
  2. 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'.
  3. Final Answer:

    Connect GitHub repo, set build command 'npm run build', output directory 'public' -> Option A
  4. Quick Check:

    GitHub + build + 'public' output folder = proper deploy [OK]
Hint: Build with 'npm run build' and output 'public' [OK]
Common Mistakes:
  • Using 'npm run dev' which is for local development
  • Setting output directory to 'public/build' instead of 'public'
  • Skipping build command causing no production files
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard