A live crypto price tracker built with SvelteKit + TypeScript + Vite, powered by the free CoinGecko API (no API key required).
š Live demo: https://svelte-from-zero.vercel.app
npm install
npm run dev
Every commit on the main branch is one teaching step. Clone the repo and walk through them with git log --oneline to see the project grow.
/coin/[id] with market dataSvelteKit uses a convention-over-config layout:
src/
āāā app.html Root HTML shell ā %sveltekit.head% + %sveltekit.body%
āāā app.css Global styles (imported once from +layout.svelte)
āāā app.d.ts Ambient TS types for App.Locals / PageData / Error
āāā routes/
āāā +layout.svelte Wraps every page with shared chrome
āāā +page.svelte The "/" route
svelte.config.js wires adapter-auto (Vercel-compatible) and vitePreprocess (so <script lang="ts"> just works).
We keep Tailwind-style utilities inline (class-based) but written in a single CSS file ā no build-time JIT needed. The layout adds a sticky header, centered container, and the muted navy palette shared across every page.
One typed module, src/lib/api.ts, wraps all CoinGecko calls:
getTopCoins(limit) ā /coins/marketsgetCoin(id) ā /coins/{id}getCoinChart(id, days) ā /coins/{id}/market_chartTyped response shapes prevent the usual "why is price_change_percentage_24h undefined?" surprises.
+page.ts (a SvelteKit load function) fetches the top-50 list on the server so the first paint already has data. The page component consumes data.coins as a typed prop.
A single $state-reactive variable filters the loaded list client-side ā no extra API call per keystroke. The filter matches on both name and symbol.
Dynamic route /coin/[id]/+page.ts reads the URL param, calls the API, and renders a full market panel: price, rank, supply, ATH, ATL, volume, market cap.
We request market_chart?days=7 and render the result as a single <svg> <polyline>. No chart library ā ~30 lines of code. The sparkline auto-scales to its container and uses a gradient stroke.
adapter-auto detects Vercel automatically. Push to GitHub, import the repo in the Vercel dashboard (or vercel --prod from CLI), done. No env vars required.
MIT ā learn, fork, break, rebuild.