What is the purpose of the static adapter in SvelteKit?
The static adapter generates a fully static version of your SvelteKit app. It pre-renders pages as HTML files so you can deploy your site to any static hosting service without a server.
Click to reveal answer
beginner
How do you configure the static adapter in a SvelteKit project?
You install the adapter with npm and then import it in your svelte.config.js file. Inside the config, you set the adapter to the static adapter, like this: <br><code>import adapter from '@sveltejs/adapter-static';<br>export default { kit: { adapter: adapter() } };</code>
Click to reveal answer
intermediate
What is prerendering in the context of static adapter deployment?
Prerendering means generating HTML pages at build time instead of on the server at runtime. The static adapter prerenders pages so they can be served as simple HTML files, improving speed and allowing static hosting.
Click to reveal answer
beginner
Which folder contains the generated static files after building with the static adapter?
The static files are generated in the build folder by default. This folder contains all the HTML, CSS, JS, and assets ready to be uploaded to a static host.
Click to reveal answer
intermediate
Can you use dynamic server-side features with the static adapter?
No, the static adapter only supports static content. Features that require a server, like server-side API routes or dynamic rendering, won't work because the site is fully static.
Click to reveal answer
What does the static adapter in SvelteKit produce?
AA serverless function bundle
BA fully static site with pre-rendered HTML files
CA client-only single page app
DA Node.js server for dynamic rendering
✗ Incorrect
The static adapter generates a fully static site by pre-rendering pages as HTML files.
Where do you specify the static adapter in a SvelteKit project?
AIn svelte.config.js under kit.adapter
BIn package.json scripts
CIn the main.js entry file
DIn the index.html file
✗ Incorrect
The adapter is configured in svelte.config.js inside the kit.adapter property.
Which command builds a static site using the static adapter?
Anpm run dev
Bnpm run static
Cnpm start
Dnpm run build
✗ Incorrect
The build command generates the static files using the configured adapter.
What happens if your app uses server-side API routes with the static adapter?
AThey are converted to client-side fetch calls
BThey run as serverless functions automatically
CThey will not work because the site is fully static
DThey are ignored but do not cause errors
✗ Incorrect
Server-side API routes require a server and won't work with a fully static site.
Which folder contains the static site output after building?
Abuild
Bsrc
Cpublic
Dnode_modules
✗ Incorrect
The build folder contains the generated static files ready for deployment.
Explain how the static adapter changes the way a SvelteKit app is deployed and what benefits it offers.
Think about what happens at build time and how the site runs after deployment.
You got /5 concepts.
Describe the steps to set up and build a SvelteKit project using the static adapter.
Focus on configuration and commands.
You got /5 concepts.
Practice
(1/5)
1. What is the main purpose of the static adapter in a SvelteKit project?
easy
A. To add real-time communication features
B. To enable server-side rendering with dynamic data
C. To connect the app to a database automatically
D. To generate static files for hosting without a backend server
Solution
Step 1: Understand what static adapter does
The static adapter converts your SvelteKit app into static files like HTML, CSS, and JS.
Step 2: Identify the hosting benefit
These static files can be hosted easily on any static hosting service without needing a backend server.
Final Answer:
To generate static files for hosting without a backend server -> Option D
Quick Check:
Static adapter = static files for hosting [OK]
Hint: Static adapter means no backend, just static files [OK]
Common Mistakes:
Confusing static adapter with server-side rendering
Thinking it connects to databases
Assuming it adds dynamic real-time features
2. Which code snippet correctly sets up the static adapter in svelte.config.js?
easy
A. export default {
kit: {
adapter: '@sveltejs/adapter-static'
}
};
B. import adapter from '@sveltejs/adapter-static';
export default {
kit: {
adapter: adapter()
}
};
C. import staticAdapter from '@sveltejs/adapter-static';
export default {
kit: {
adapter: staticAdapter
}
};
D. import adapter from '@sveltejs/adapter-node';
export default {
kit: {
adapter: adapter()
}
};
Solution
Step 1: Check import statement
The static adapter must be imported from '@sveltejs/adapter-static' and assigned to a variable.
Step 2: Confirm adapter usage
The adapter must be called as a function: adapter() inside the kit.adapter property.
Final Answer:
Correct import and adapter() call in svelte.config.js -> Option B
Quick Check:
Import + adapter() call = correct setup [OK]
Hint: Import adapter and call it as a function in config [OK]
Common Mistakes:
Forgetting to call adapter() as a function
Importing wrong adapter package
Assigning adapter without calling it
3. Given this svelte.config.js snippet, what will be the output folder after building?