What is the purpose of the src folder in a Svelte project?
The src folder holds all the source code files like components, styles, and scripts that make up the app. It's where you write your app's logic and UI.
Click to reveal answer
beginner
What does the public folder contain in a Svelte project?
The public folder contains static files like images, icons, and the main index.html file. These files are served directly to the browser without processing.
Click to reveal answer
beginner
Why is the package.json file important in a Svelte project?
It lists the project dependencies, scripts to run or build the app, and metadata. It helps manage packages and commands for your project.
Click to reveal answer
beginner
What role does the node_modules folder play in a Svelte project?
It stores all the installed packages and libraries your project depends on. You usually don't edit files here; it's managed by the package manager.
Click to reveal answer
beginner
Where do you place reusable UI parts like buttons or headers in a Svelte project?
Reusable UI parts are usually placed inside the src/lib or src/components folder to keep the code organized and easy to find.
Click to reveal answer
Which folder in a Svelte project contains the main HTML file served to the browser?
Asrc
Bpublic
Cnode_modules
Dlib
✗ Incorrect
The public folder contains static files like index.html that the browser loads directly.
Where do you write your Svelte components and app logic?
Asrc
Bpublic
Cnode_modules
Dpackage.json
✗ Incorrect
The src folder is where you write your components, styles, and scripts.
What is the main purpose of the package.json file?
AManage dependencies and scripts
BSave user data
CHold compiled code
DStore static images
✗ Incorrect
It manages project dependencies and scripts like build or start commands.
Which folder should you avoid editing directly because it is managed by the package manager?
Asrc
Bpublic
Cnode_modules
Dlib
✗ Incorrect
The node_modules folder is managed automatically and contains installed packages.
Where do you typically put reusable UI components in a Svelte project?
Apackage.json
Bpublic
Cnode_modules
Dsrc/components or src/lib
✗ Incorrect
Reusable components are organized inside src/components or src/lib folders.
Describe the main folders and files in a Svelte project and their roles.
Think about where you write code, where static files live, and how dependencies are managed.
You got /5 concepts.
Explain why organizing your Svelte project structure well helps in development.
Consider how a tidy workspace helps you work faster and avoid confusion.
You got /5 concepts.
Practice
(1/5)
1. In a Svelte project, where should you place reusable components that can be used across multiple pages?
easy
A. static/components
B. src/routes
C. src/lib
D. public/assets
Solution
Step 1: Understand folder purpose
src/lib is designed for reusable components and utilities.
Step 2: Compare with other folders
src/routes holds pages, public/assets is for static files, and static/components is not a standard folder.
Final Answer:
src/lib -> Option C
Quick Check:
Reusable components = src/lib [OK]
Hint: Reusable parts go in src/lib folder [OK]
Common Mistakes:
Putting reusable components in src/routes
Using public folder for components
Creating non-standard folders like static/components
2. Which of the following is the correct folder to place page files in a SvelteKit project?
easy
A. src/pages
B. src/lib
C. public/pages
D. src/routes
Solution
Step 1: Identify the folder for pages
In SvelteKit, src/routes is the folder where page components live.
Step 2: Check other options
src/lib is for reusable components, public/pages and src/pages are not standard folders for pages.
Final Answer:
src/routes -> Option D
Quick Check:
Pages go in src/routes [OK]
Hint: Pages always go in src/routes in SvelteKit [OK]
Common Mistakes:
Confusing src/lib with src/routes
Placing pages in public folder
Using non-standard src/pages folder
3. Given the following SvelteKit project structure:
Where should you import the Button.svelte component to use it on the homepage?
medium
A. From ./Button.svelte inside src/routes/index.svelte
B. From ../lib/Button.svelte inside src/routes/index.svelte
C. From ../../public/logo.png inside src/routes/index.svelte
D. From public/Button.svelte inside src/routes/index.svelte
Solution
Step 1: Understand folder hierarchy
src/routes/index.svelte is one level deeper than src/lib/Button.svelte, so import path is ../lib/Button.svelte.
Step 2: Eliminate wrong paths
../../public/logo.png is for static assets, not components; ./Button.svelte assumes Button is in routes folder; public/Button.svelte is incorrect location.
Final Answer:
From ../lib/Button.svelte inside src/routes/index.svelte -> Option B
Quick Check:
Import reusable components with relative path ../lib [OK]
Hint: Use relative path ../lib to import components from routes [OK]
Common Mistakes:
Trying to import components from public folder
Using wrong relative path like ./Button.svelte
Confusing static assets with components
4. You placed an image file inside src/lib/images and tried to use it in your SvelteKit page, but it doesn't load in the browser. What is the most likely reason?
medium
A. Static assets must be inside the public folder to be served correctly.
B. Images must be imported from src/routes folder only.
C. You need to rename the image file to have a .svelte extension.
D. The image file size is too large to load.
Solution
Step 1: Understand static asset serving
SvelteKit serves static files only from the public folder, so files in src/lib/images are not accessible directly.
Step 2: Check other options
Images don't belong in src/routes, renaming to .svelte is incorrect, and file size doesn't prevent loading if path is correct.
Final Answer:
Static assets must be inside the public folder to be served correctly. -> Option A
Quick Check:
Static files go in public folder [OK]
Hint: Put images in public folder to load in browser [OK]
Common Mistakes:
Placing images inside src/lib or src/routes
Renaming images as .svelte files
Assuming large file size causes loading failure
5. You want to organize your SvelteKit project so that: 1. All page routes are inside src/routes. 2. Reusable UI components are inside src/lib/components. 3. Static assets like images and fonts are inside public/assets.
Which folder structure below correctly reflects this setup?