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!