Back to Calendar

Day 14 Remote Functions: Prerender

Some data changes with every request, but other data only changes when you deploy. Why fetch it fresh every time? Remote Prerender Functions let you bake data into your build like cookies for Santa!

Import prerender from $app/server in your .remote.ts file, declare your function, and use it just like a query. The magic happens at build time: SvelteKit executes the function and saves the result to disk. In production, your server delivers a static file instead of running expensive database queries or API calls.

This unlocks partial prerendering at the data level, not just the page level. On Santa's workshop dashboard, for example, the comments list stays dynamic and fresh, while the overview stats — which only change per deployment — are prerendered and served instantly from the CDN.

Mix static and dynamic data on the same page with surgical precision. Stay tuned for more Remote Functions goodness!

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