The fastest way to launch a stateful backend
View state machine
In this example, we will create an email automation backend. We built our logic visually as a state machine and can deploy our machine as a serverless, durable backend in one command with State Backed.
Take a look at the statebacked directory on GitHub to see the entire backend for this example. You'll notice that the only code we wrote was the state machine that represents our business logic. No accidental complexity, no configuration, no persistence handling, no boilerplate.
You can see the simple frontend interactions with our backend in SampleApp.tsx. We retrieve a State Backed token from backend and then create, get, and send events to our state machine instance. Our UI is a simple function of the state machine's current state.
This example requires long-running timers (we send emails after a multi-day delay, though, for example purposes, we have shortened days to minutes and minutes to seconds). For that, we just rely on the durable timers provided by State Backed by way of standard XState delay support.
Typically, you would have to create at least two separate sets of infrastructure to support an email automation flow: one set of services to handle the email sending logic and another set of services to capture and update the user state logic. Here, we handle both quite naturally in the same state machine and don't need to worry about any of the underlying infrastructure.
You can deploy your own state machine backend in less than 5 minutes with State Backed. 1,000 events and 10,000 reads free every month.
Powered by State Backed