Back to Calendar

Day 11 resolve and asset

The 404 monster lurks in every codebase, waiting to pounce on typos and broken links. But fear not — SvelteKit 2.26 brought two trusty helpers to keep your routes and assets safe: resolve and asset from $app/paths.

The resolve function is your type-safe compass for navigation. Pass it a route ID and SvelteKit validates it against your actual routes — typos light up red in your editor before they ever reach production. Even dynamic routes like /tree/[name] get proper parameter handling, ensuring every path leads somewhere real.

For static files, asset wraps your references to the static folder with autocomplete and validation. No more wondering if it's /elf.svg or /elves.svg — your editor knows what's in Santa's bag!

Pair these with ESLint (npx sv add eslint) to scan your entire codebase for unsafe routes. And when requirements change — like serving everything from /advent-of-svelte-2025 — just update your config. All your resolve calls automatically include the new base path. The 404 monster doesn't stand a chance!

Read the docs

Credits

Illustrations by Icons 8:

  • Santa Hat
  • Santa sleigh
  • Cookie
  • Heart
  • Santa face
  • Present
  • ID
  • Snowflake
  • Snow Globe
  • Question Mark
  • Fairy Lights
  • Piggy Bank
  • Globe
  • Present #2

Illustrations by Elisabet Guba:

  • Clock

Icons by Obra Icons

Challenges by Svelte Ambassadors:

  • Stanislav Khromov
  • Willow (GHOST)
  • Paolo Ricciuti

Santa Tracker Data by NORAD via Danielle Vass