Back to Calendar

Day 15 Remote Functions: Commands

Sometimes you need to trigger server-side logic without a form — like when an elf clicks a button to mark a gift as wrapped. That's where Remote Command Functions come in!

Import command from $app/server in your .remote.ts file, define a schema for validation and type safety, and call it directly from your component. Unlike forms, commands require JavaScript — but they give you the flexibility to trigger mutations from any event handler.

By default, commands don't refresh any queries — you're in full control. Want the UI to update? Add a refresh call to fetch new data alongside the mutation. It's the same single-flight mutation pattern from form functions: one round trip to the server, mutation plus fresh data back in your hands.

With just a few lines of code, you get type-safe, input-validated remote commands. Perfect for those interactive dashboard moments when Santa needs to mark items as processed!

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