Organisms adapt to fluctuating environments by regulating their dynamics, and by adjusting their phenotypes to environmental changes. We model population growth using multitype branching processes in random environments, where the offspring distribution of some organism having trait t ∈ in environment e ∈ ε is given by some (fixed) distribution ϒt,e on ℕ. Then, the phenotypes are attributed using a distribution (strategy) πt,e on the trait space . We look for the optimal strategy πt,e, t ∈ , e ∈ ε, maximizing the net growth rate or Lyapounov exponent, and characterize the set of optimal strategies. This is considered for various models of interest in biology: hereditary versus nonhereditary strategies and strategies involving or not involving a sensing mechanism. Our main results are obtained in the setting of nonhereditary strategies: thanks to a reduction to simple branching processes in a random environment, we derive an exact expression for the net growth rate and a characterization of optimal strategies. We also focus on typical genealogies, that is, we consider the problem of finding the typical lineage of a randomly chosen organism.