Workflows and custom features
Simple workflows#
A simple workflow has a state, the state shows the screen, and the screen has a button that is always there in that state. If there's an error, it doesn't advance, and the user clicks again. If it stops at any moment, the user reloads the page and clicks the same button. It doesn't execute several things in the back-end, and the user is present.
Simple workflows, such as multi-step asynchronous forms, are built with nested forms. Having a workflow is not a reason to reach for a workflow engine: in most business cases an employee is there following the process.
The workflow's record#
A workflow is usually accompanied by a record in the database, and its state lives in that record. When a result must
not be lost if the user closes the page, the workflow creates its record first with status pending, and the record
gets status error when something goes wrong. The interface shows that it went wrong, with a retry button. That is
the MVP solution: no automatic retries.
Backend workflows#
Workflows that run in the back-end use the Vercel Workflow SDK. A server action starts them. Most of the time the client starts the workflow after it has the response of the write that precedes it.
Custom features#
A custom feature is something written by hand: a custom state management or a state machine, like a piece of a game,
or following an active workflow while it executes, with polling. Its state lives in the page's context.tsx and
hooks.tsx.