React-like State Management for Workflow Components

Currently, Pipedream components are stateless between workflow executions. Each run creates a fresh component instance with default prop values, making it impossible to maintain state across workflow runs without using external storage mechanisms like $.flow.setState().

// This doesn't work - props reset to default values between runs
export default defineComponent({
  props: {
    purchases: { 
      type: "integer",
      default: 26
    }
  },
  async run({ steps, $ }) {
    // This always starts at 26, never persists
    const storedPurchases = this.purchases;
    const newPurchases = await getNewPurchases();
    
    if (newPurchases > storedPurchases) {
      this.purchases = newPurchases; // Doesn't persist between runs
    }
  }
});

Proposed Solution

Enable persistent component state that maintains prop values between workflow executions, similar to React component state management.

export default defineComponent({
  props: {
    purchases: { 
      type: "integer",
      default: 26,
      persistent: true  // new flag
    }
  },
  async run({ steps, $ }) {
    const storedPurchases = this.purchases; // Gets persisted value
    const newPurchases = await getNewPurchases();
    
    if (newPurchases > storedPurchases) {
      this.purchases = newPurchases; // Persists between runs
      // Continue with expensive operation
    } else {
      return { skip: true, reason: "No changes detected" };
    }
  }
});

There is no need to make a request to flow state and it lowers compute costs for simple counter props that don’t need to be stored.

You can use data stores for state management

Yes I know, the original post was suppose to use the data stores API. But using data stores is unnecessary. The proposal is that using data stores for something like a counter is overkill. Being able to maintain the state (e.g. native web component setter/getter or react state mgmt) would allow us to maintain states within the workflow step without extra calls or storage needs with the added ability to dynamically update the static props assigned.

Gotcha, but frankly, this feature request won’t get prioritized since there are other ways of achieving what you’re asking for, so I recommend using data stores anyway.

Would have marked this as a nice-to-have but there wasn’t an option. No expectation that it will be prioritized. Being able carry over variables into the next step seamlessly without data stores is a super awesome feature and it would be cool to handle states and props in a similar way without the dependency on additional resources. Thank you!