What is the SvelteKit module system and $lib, $app imports?

Answer

SvelteKit provides several virtual module aliases for clean imports. $lib: resolves to src/lib — your shared components, utilities, and stores. import Button from '$lib/components/Button.svelte'; instead of relative paths. $app/stores: built-in stores — page (current URL, route params, data), navigating (navigation in progress), updated (whether the deployed app has changed). $app/navigation: navigation functions — goto, invalidate, invalidateAll, preloadData, pushState, replaceState, beforeNavigate, afterNavigate. $app/environment: browser (true in browser), dev (true in dev mode), building (true during static prerender). $app/forms: enhance, applyAction, deserialize. $env/static/private, $env/static/public, etc.: environment variables. Custom aliases are configured in svelte.config.js under kit.alias.