Spin Application Idioms
https://leanpub.com/building-serverless-apps-with-wasm-and-spinThe Spin Application Manifest
https://leanpub.com/building-serverless-apps-with-wasm-and-spinManifest Version and Core Metadata
https://leanpub.com/building-serverless-apps-with-wasm-and-spinTriggers and Components
https://leanpub.com/building-serverless-apps-with-wasm-and-spinHTTP Routing Wildcards
https://leanpub.com/building-serverless-apps-with-wasm-and-spinThe Component build Table
https://leanpub.com/building-serverless-apps-with-wasm-and-spinCapabilities: Deny by Default
https://leanpub.com/building-serverless-apps-with-wasm-and-spinBuild Profiles
https://leanpub.com/building-serverless-apps-with-wasm-and-spinComponent Dependencies
https://leanpub.com/building-serverless-apps-with-wasm-and-spinConfiguration with Spin Variables
https://leanpub.com/building-serverless-apps-with-wasm-and-spinDeclaring Variables
https://leanpub.com/building-serverless-apps-with-wasm-and-spinMapping Variables to Components
https://leanpub.com/building-serverless-apps-with-wasm-and-spinReading Spin Variables from Rust
https://leanpub.com/building-serverless-apps-with-wasm-and-spinVariable Providers and Precedence
https://leanpub.com/building-serverless-apps-with-wasm-and-spinUsing Environment Variables
https://leanpub.com/building-serverless-apps-with-wasm-and-spinDefining and Using Environment Variables
https://leanpub.com/building-serverless-apps-with-wasm-and-spinEnvironment Variables vs. Spin Variables
https://leanpub.com/building-serverless-apps-with-wasm-and-spinSpin Trigger Types
HTTP is the trigger we’ve used so far, but it isn’t the only one Spin offers. Before we build the Task-Engine, it’s worth taking a quick tour of available Spin trigger types so you know they exist and understand, concretely, when you might want to use them, or not.
Non-HTTP Triggers
Spin’s trigger types share the same model (a portable WebAssembly component with a deny-by-default capability grant) and differ only in what invokes the component. HTTP ships in the core runtime; the rest are either built in (Redis) or installed as trigger plugins.
Here is a quick look at popular trigger types other than HTTP:
The Redis Trigger
The Redis trigger invokes a component every time a message is published to a Redis (or Valkey) pub/sub channel. It’s the classic event-driven pattern: a producer publishes a “task created” message, and a subscriber component reacts off the request path. The [[trigger.redis]] table binds a channel to a component:
[[trigger.redis]]
address = "redis://localhost:6379"
channel = "messages"
component = "subscribe"
It’s a genuinely good fit when you already run Redis or Valkey and want event fan-out. You can find full details in the Redis trigger documentation.
The SQS Trigger
The SQS trigger invokes a component when a message arrives on an AWS SQS queue: the same event-driven idea, but backed by a managed cloud queue instead of your own Redis. The trigger long-polls the queue and hands each message to the component:
[[trigger.sqs]]
queue_url = "http://localhost:9324/000000000000/test-queue"
max_messages = 1
idle_wait_seconds = 3
system_attributes = ["All"]
message_attributes = ["glonk"]
component = "sqs-consumer"
It’s a plugin; source and details live in spinframework/spin-trigger-plugins (crate trigger-sqs).
The MQTT Trigger
The MQTT trigger connects to an MQTT broker and invokes a component when a message lands on a subscribed topic: the go-to for IoT and device-telemetry workloads. The broker connection is declared once; each [[trigger.mqtt]] subscribes a component to a topic (MQTT wildcards like + are allowed):
[application.trigger.mqtt]
address = "mqtt://localhost:1883"
username = "admin"
password = "password"
keep_alive_interval = "30"
[[trigger.mqtt]]
id ="telemetry-trigger"
component = "telemetry-handler"
topic = "sensors/+"
qos = "1"
It is also a plugin; see spinframework/spin-trigger-plugins (crate trigger-mqtt).
The Command Trigger
The command trigger runs a component once, to completion, and then exits — no server, no port, no long-lived process. It’s the closest thing Spin has to a plain CLI program (it executes the wasi:cli run export), which makes it the natural home for one-shot jobs: a migration, a backfill, or a seeder. It’s also the recommended shape for a Kubernetes Job under SpinKube, where a cron trigger has nothing to schedule against.
[[trigger.command]]
component = "seed-data"
Plugin source: spinframework/spin-trigger-plugins (crate trigger-command).
The Cron Trigger
The cron trigger invokes a component on a schedule (“every five minutes” or “at midnight”) with no external request at all, driven by Spin’s own scheduler:
[[trigger.cron]]
component = "nightly-sweep"
cron_expression = "0 */5 * * * *" # Every 5 minutes
Plugin source: spinframework/spin-trigger-plugins (crate trigger-cron).
So we have purpose-built command and cron triggers, plus three event-driven triggers (Redis, SQS, and MQTT) that could each carry “react to something that happened.” For the Task-Engine, our end-to-end sample application, HTTP wins on the one axis we care about most: Portability.
Next, we dive into actually building Task-Engine.