0
0
Svelteframework~20 mins

SvelteKit overview - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
SvelteKit Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
What happens when you navigate between pages in SvelteKit?

Consider a SvelteKit app with multiple pages. What is the main behavior when you click a link to go from one page to another?

AThe app shows a blank page until the new page fully loads from the server.
BThe browser reloads the entire page from the server, losing all current state.
CThe navigation is blocked unless the user refreshes the browser manually.
DSvelteKit intercepts the navigation and updates only the changed parts without a full reload.
Attempts:
2 left
💡 Hint

Think about how modern apps avoid full page reloads to feel faster.

📝 Syntax
intermediate
1:30remaining
Which SvelteKit file defines a page route?

In a SvelteKit project, which file path correctly defines a page route for the URL /about?

Asrc/routes/about/+page.svelte
Bsrc/pages/about.svelte
Csrc/components/about.svelte
Dsrc/routes/about/index.js
Attempts:
2 left
💡 Hint

Routes are defined inside the src/routes folder with +page.svelte files for pages.

lifecycle
advanced
2:00remaining
When is the load function called in SvelteKit?

In SvelteKit, the load function can be exported from a page or layout. When does this function run?

AOnly when the user refreshes the browser manually.
BOnly once when the app first loads in the browser.
CEvery time the page or layout is rendered on the server or client during navigation.
DOnly when the page is built during deployment.
Attempts:
2 left
💡 Hint

Think about when data needs to be fetched for each page visit.

🔧 Debug
advanced
2:30remaining
Why does this SvelteKit page fail to load data?

Given this +page.server.js file in SvelteKit:

export async function load() {
  const res = await fetch('/api/data');
  const data = await res.json();
  return { data };
}

The page shows an error: fetch is not defined. Why?

ABecause <code>fetch</code> is not available in server-side load functions by default.
BBecause the API endpoint <code>/api/data</code> does not exist.
CBecause the load function must be named <code>loadData</code> instead of <code>load</code>.
DBecause the <code>load</code> function must return a Promise, not an object.
Attempts:
2 left
💡 Hint

Remember that server-side code may not have browser APIs like fetch globally.

🧠 Conceptual
expert
3:00remaining
How does SvelteKit handle server-side rendering (SSR) and client-side hydration?

Which statement best describes how SvelteKit combines server-side rendering and client-side hydration?

ASvelteKit renders pages on the server and disables all client-side JavaScript to improve performance.
BSvelteKit renders pages on the server to HTML, then sends them to the browser where Svelte hydrates the page to make it interactive.
CSvelteKit sends raw Svelte components to the browser and compiles them there for rendering.
DSvelteKit only renders pages on the client; server-side rendering is disabled by default.
Attempts:
2 left
💡 Hint

Think about how modern frameworks deliver fast initial loads and interactivity.