Custom Class Serialization in Workflow SDK
By Steven Van ·
A new @workflow/serde package adds WORKFLOW_SERIALIZE and WORKFLOW_DESERIALIZE methods so custom classes can cross the workflow/step boundary.
Vercel's Workflow SDK now supports custom class serialization, letting custom class instances be passed between workflow and step functions. The SDK already serialized standard JavaScript types like primitives, objects, arrays, Date, Map, and Set, but custom classes weren't supported because the serialization system didn't know how to reconstruct them.
A new @workflow/serde package fixes this: implementing two static methods, WORKFLOW_SERIALIZE and WORKFLOW_DESERIALIZE, on a class tells the SDK how to convert instances to plain data and back. Once implemented, instances of that class can be used as arguments and return values across the workflow/step boundary, with the conversion handled automatically. Vercel says it used this to improve the developer experience in @vercel/sandbox.
