Skip to main content

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.

Vercel
Vercel
The platform for frontend developers — deploy, preview, and scale web apps and AI agents with zero config.
View Vercel →

Read the original announcement →

Read Custom Class Serialization in Workflow SDK on Creators Toolbox