As far as I know, while on a H1B, you can definitely start something on the side, but you can't get a salary for this activity legally. So as long as you are just coding and developing an app, for example is perfectly fine. This can be your 'hobby' and if this 'hobby' gets good traction and you want to convert it to a company then you'll run into all the legal issues pointed here. However, by then if you can convince investors and raise money with a board of directors you are in good shape.
I'm not an immigration lawyer, so those guys will give you the best advice. Please consult one.
I'm not an immigration lawyer, so those guys will give you the best advice. Please consult one.