Power generation side energy storage plant can improve the reliability of renewable energy power generation, and is conducive to the electrolysis of water to produce hydrogen for new energy consumption, so this paper proposes a method for optimising the capacity allocation of hydrogen microgrids by considering shared energy storage for the capacity allocation of hydrogen microgrids.Firstly, a two-layer planning model for the hydrogen microgrid is established by considering the cooperative alliance mechanism between renewable energy power stations and shared energy storage. In the two-layer planning model, the upper layer takes into account the complementary characteristics and volatility of the typical scenarios of wind and photovoltaic power generation, and establishes an optimization model of the capacity allocation of the hydrogen microgrid by taking the net benefit of the participants of the game in the cooperative alliance in the whole life cycle as the optimization objective; the lower layer takes the o