Since v11, the runtime representation of variants is stable and part of the language, so in those terms it’s safe to use variants - we won’t be changing their runtime representation.
As to whether it’s suitable, as long as you’re only passing things that can be serialized with JSON (or whatever serialization you’re using), then it’s great. Also following rules for how to evolve your types and so on to be backwards compatible, but that seems out of scope for this discussion. Passing things that can’t be automatically serialized/parsed back (like Date.t
) seems like the biggest risk.