The recent sharp decline in the cost of renewable energy suggests that the production of hydrogen from renewable power through a power-to-gas process might become more economical. Here we examine this alternative from the perspective of an investor who considers a hybrid energy system that combines renewable power with an efficiently sized power-to-gas facility. The available capacity can be optimized in real time to take advantage of fluctuations in electricity prices and intermittent renewable power generation. We apply our model to the current environment in both Germany and Texas and find that renewable hydrogen is already cost competitive in niche applications ((sic)3.23 kg(-1)), although not yet for industrial-scale supply. This conclusion, however, is projected to change within a decade ((sic)2.50 kg(-1)) provided recent market trends continue in the coming years.